This commit is contained in:
gsinghpal
2026-05-21 04:47:45 -04:00
parent 3440e4b7c6
commit d6d6249857
10 changed files with 610 additions and 301 deletions

View File

@@ -5,7 +5,7 @@
{
'name': 'Fusion Plating — Logistics',
'version': '19.0.3.10.0',
'version': '19.0.3.11.0',
'category': 'Manufacturing/Plating',
'summary': (
'Pickup & delivery for plating shops: vehicle master, driver '

View File

@@ -260,6 +260,58 @@ class FpDelivery(models.Model):
def _fp_parent_counter_field(self):
return 'x_fc_pn_delivery_count'
def action_view_coc(self):
"""Open the certificate record this delivery's CoC PDF came
from. The attachment carries res_model + res_id, so we
navigate to that record (operator gets all cert info — issue
date, void wizard, reset, etc.) rather than just opening the
raw PDF. Falls back to opening the attachment directly if
someone manually attached a PDF that isn't a cert.
"""
self.ensure_one()
att = self.coc_attachment_id
if not att:
raise UserError(_('No CoC linked to this delivery.'))
if att.res_model == 'fp.certificate' and att.res_id:
return {
'type': 'ir.actions.act_window',
'name': _('Certificate of Conformance'),
'res_model': 'fp.certificate',
'res_id': att.res_id,
'view_mode': 'form',
'target': 'current',
}
# Plain attachment — open via PDF preview helper if available.
if hasattr(att, 'action_fusion_preview'):
return att.action_fusion_preview(title=att.name or 'CoC')
return {
'type': 'ir.actions.act_url',
'url': '/web/content/%d?download=false' % att.id,
'target': 'new',
}
def action_view_packing_list(self):
"""Open the packing-list PDF via fusion_pdf_preview (or fall
back to a new tab when the preview helper isn't installed).
Packing lists don't have a backing model — they're attachments
only — so we don't navigate to a record.
"""
self.ensure_one()
att = self.packing_list_attachment_id
if not att:
raise UserError(_('No packing list attached to this delivery.'))
if hasattr(att, 'action_fusion_preview'):
return att.action_fusion_preview(
title=att.name or 'Packing List',
model_name=self._name,
record_ids=self.id,
)
return {
'type': 'ir.actions.act_url',
'url': '/web/content/%d?download=false' % att.id,
'target': 'new',
}
def action_refresh_from_source(self):
"""Re-pull delivery address / contact / scheduled date / source
facility / carrier / CoC from the linked job → SO → receiving →

View File

@@ -79,6 +79,30 @@
widget="statinfo"
string="Outbound Shipment"/>
</button>
<!-- CoC smart button → cert record (not the
raw PDF — operator can print/reset/void
from the cert form). -->
<button name="action_view_coc"
type="object"
class="oe_stat_button"
icon="fa-certificate"
invisible="not coc_attachment_id">
<div class="o_field_widget o_stat_info">
<span class="o_stat_text">CoC</span>
</div>
</button>
<!-- Packing list smart button → PDF preview
dialog (packing lists are attachments
only, no backing model to navigate to). -->
<button name="action_view_packing_list"
type="object"
class="oe_stat_button"
icon="fa-list-alt"
invisible="not packing_list_attachment_id">
<div class="o_field_widget o_stat_info">
<span class="o_stat_text">Packing List</span>
</div>
</button>
</div>
<div class="oe_title">
<label for="name"/>