This commit is contained in:
gsinghpal
2026-04-26 15:05:17 -04:00
parent 160198edb1
commit d9f58b9851
110 changed files with 6210 additions and 1182 deletions

View File

@@ -12,19 +12,18 @@ class FpDelivery(models.Model):
def action_mark_delivered(self):
res = super().action_mark_delivered()
Dispatch = self.env['fp.notification.template']
Job = self.env.get('fp.job')
for rec in self:
if not rec.partner_id:
continue
so = False
if rec.job_ref:
# Delivery's job_ref is the MO name; find the SO via MO origin.
mo = self.env['mrp.production'].search(
[('name', '=', rec.job_ref)], limit=1,
)
if mo and mo.origin:
so = self.env['sale.order'].search(
[('name', '=', mo.origin)], limit=1,
)
# Native: fp.job direct link.
if Job is not None and 'x_fc_job_id' in rec._fields and rec.x_fc_job_id:
so = rec.x_fc_job_id.sale_order_id or False
elif Job is not None and rec.job_ref:
job = Job.search([('name', '=', rec.job_ref)], limit=1)
if job:
so = job.sale_order_id or False
# Sub 6 — pass the delivery address so location-scoped
# contacts receive the 'shipped' notification.
Dispatch._dispatch(