This commit is contained in:
gsinghpal
2026-05-21 03:37:25 -04:00
parent b2f483d67c
commit 1314f4581d
47 changed files with 5730 additions and 177 deletions

View File

@@ -2459,13 +2459,29 @@ class DeliveryCarrier(models.Model):
def fusion_fedex_rest_send_shipping(self, pickings):
res = []
srm = FedexRestRequest(self)
# Per-shipment service override — fp.receiving sets this on the
# carrier via with_context() before calling send_shipping. Empty
# falls back to the carrier-level default already on srm.
# See CLAUDE.md "Per-shipment service override".
override = self.env.context.get('fp_service_type_override')
if override:
srm.service_type = override
for picking in pickings:
packages = self._get_packages_from_picking(picking, self.fedex_rest_default_package_type_id)
# SoldTo defaults to the SO's invoice partner, but many setups
# leave the parent contact (used as invoice fallback) with a
# name-only record and no address — FedEx rejects on `soldTo.
# address.city cannot be null`. If the invoice partner has no
# city, treat ship-to as sold-to so _ship_package skips the
# soldTo block entirely (line guard: `if sold_to != ship_to`).
invoice_partner = picking.sale_id.partner_invoice_id
if not (invoice_partner and invoice_partner.city):
invoice_partner = picking.partner_id
response = srm._ship_package(
ship_from_wh=picking.picking_type_id.warehouse_id.partner_id,
ship_from_company=picking.company_id.partner_id,
ship_to=picking.partner_id,
sold_to=picking.sale_id.partner_invoice_id,
sold_to=invoice_partner,
packages=packages,
currency=picking.sale_id.currency_id.name or picking.company_id.currency_id.name,
order_no=picking.sale_id.name,

View File

@@ -267,10 +267,22 @@ class FusionShipment(models.Model):
}
def _action_open_attachment(self, attachment):
"""Open an attachment PDF in the browser viewer (new tab)."""
"""Open an attachment for the operator.
Delegates to ir.attachment.action_fusion_preview — PDFs render
in the preview dialog, anything else (ZPL, etc.) downloads.
Helper falls back gracefully when fusion_pdf_preview isn't
installed. See CLAUDE.md "PDF Preview" for the contract.
"""
self.ensure_one()
if not attachment:
return False
if hasattr(attachment, 'action_fusion_preview'):
return attachment.action_fusion_preview(
title=attachment.name or 'Shipping Label',
model_name=self._name,
record_ids=self.id,
)
return {
'type': 'ir.actions.act_url',
'url': '/web/content/%s?download=false' % attachment.id,