changes
This commit is contained in:
@@ -10,7 +10,8 @@ here (not in fusion_shipping) to keep the upstream module untouched.
|
||||
"""
|
||||
import logging
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -41,6 +42,42 @@ class FusionShipment(models.Model):
|
||||
copy=False,
|
||||
)
|
||||
|
||||
# Separate slot for the ZPL version of the label. FedEx (and most
|
||||
# carriers) return one format per ship-call; the primary
|
||||
# label_attachment_id holds whatever the carrier was configured to
|
||||
# return (we default to PDF). This field is populated only when a
|
||||
# ZPL variant has been fetched explicitly. Two slots = two smart
|
||||
# buttons on the receiving form, one per format.
|
||||
x_fc_label_zpl_attachment_id = fields.Many2one(
|
||||
'ir.attachment',
|
||||
string='ZPL Label',
|
||||
copy=False,
|
||||
help='ZPL/ZPLII version of the shipping label. Empty unless '
|
||||
'the carrier returned ZPL (or a ZPL fetch was triggered '
|
||||
'separately).',
|
||||
)
|
||||
|
||||
def action_view_label_zpl(self):
|
||||
"""Download the ZPL label for direct-to-thermal-printer use.
|
||||
|
||||
ZPL is text/plain — the PDF preview dialog can't render it, so
|
||||
this stays on the legacy download path (no preview, just a file
|
||||
the operator sends to their Zebra). Mirrors fp.receiving's
|
||||
action_print_label_zpl so the button exists on both forms.
|
||||
"""
|
||||
self.ensure_one()
|
||||
if not self.x_fc_label_zpl_attachment_id:
|
||||
raise UserError(_(
|
||||
'No ZPL label on this shipment. Use the PDF version, '
|
||||
'or switch the carrier label format to ZPLII and '
|
||||
'regenerate.'
|
||||
))
|
||||
return self.x_fc_label_zpl_attachment_id.action_fusion_preview(
|
||||
title=self.x_fc_label_zpl_attachment_id.name or 'ZPL Label',
|
||||
model_name=self._name,
|
||||
record_ids=self.id,
|
||||
)
|
||||
|
||||
# Phase C — resolved carrier tracking URL with the tracking number
|
||||
# substituted into the carrier.tracking_url template. Used by the
|
||||
# shipment_labeled email template and any other place that needs a
|
||||
|
||||
Reference in New Issue
Block a user