feat(fusion_shipping): Shipping Label + Commercial Invoice smart buttons on delivery order

Carriers post the shipping label and (for international) the commercial invoice
to the delivery order's chatter, where they were hard to find. Add two smart
buttons on the stock.picking form that open the latest of each via the PDF
preview dialog (fusion_pdf_preview when installed, else open in a new tab).

Document discovery is carrier-agnostic (computed from the picking's attachments):
labels match 'Label*'; invoices match '*CommercialInvoice*' (UPS/Canada Post) or
'ShippingDoc-*' (FedEx/DHL, _get_delivery_doc_prefix). Buttons hide when absent.

Verified on entech: real FedEx picking resolved its label (invoice correctly
none for a domestic ship); synthetic UPS names resolved label+invoice and the
invoice button fired fusion_pdf_preview.open_attachment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-06-04 19:24:26 -04:00
parent a86f20017d
commit 423f288507
3 changed files with 94 additions and 2 deletions

View File

@@ -6,12 +6,28 @@
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<field name="fusion_shipping_label_attachment_id" invisible="1"/>
<field name="fusion_commercial_invoice_attachment_id" invisible="1"/>
<button name="action_view_fusion_shipments" type="object"
class="oe_stat_button" icon="fa-plane"
invisible="fusion_shipment_count == 0">
<field name="fusion_shipment_count" widget="statinfo"
string="Shipments"/>
</button>
<button name="action_view_fusion_shipping_label" type="object"
class="oe_stat_button" icon="fa-print"
invisible="not fusion_shipping_label_attachment_id">
<div class="o_field_widget o_stat_info">
<span class="o_stat_text">Shipping Label</span>
</div>
</button>
<button name="action_view_fusion_commercial_invoice" type="object"
class="oe_stat_button" icon="fa-file-text-o"
invisible="not fusion_commercial_invoice_attachment_id">
<div class="o_field_widget o_stat_info">
<span class="o_stat_text">Commercial Invoice</span>
</div>
</button>
</xpath>
</field>
</record>