# -*- coding: utf-8 -*- # Copyright 2026 Nexa Systems Inc. # License OPL-1 (Odoo Proprietary License v1.0) # Part of the Fusion Plating product family. from odoo import models class FpDelivery(models.Model): _inherit = 'fusion.plating.delivery' def action_mark_delivered(self): res = super().action_mark_delivered() Dispatch = self.env['fp.notification.template'] 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, ) # Sub 6 — pass the delivery address so location-scoped # contacts receive the 'shipped' notification. Dispatch._dispatch( 'shipped', rec, rec.partner_id, sale_order=so, delivery_location=rec.delivery_address_id or False, ) return res