changes
This commit is contained in:
@@ -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 →
|
||||
|
||||
Reference in New Issue
Block a user