changes
This commit is contained in:
@@ -10,5 +10,7 @@ from . import sale_order
|
||||
from . import fp_receiving
|
||||
from . import account_move
|
||||
from . import account_payment
|
||||
from . import mrp_production
|
||||
# Phase 5 (Sub 11) — mrp.production hook retired. The native equivalent
|
||||
# fires from fp.job.button_mark_done -> _fp_fire_notification('job_complete').
|
||||
# from . import mrp_production
|
||||
from . import fp_delivery
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
# Part of the Fusion Plating product family.
|
||||
|
||||
from odoo import fields, models
|
||||
from odoo import api, fields, models
|
||||
|
||||
from .fp_notification_template import TRIGGER_EVENTS
|
||||
|
||||
@@ -29,3 +29,20 @@ class FpNotificationLog(models.Model):
|
||||
)
|
||||
error_message = fields.Text(string='Error Message')
|
||||
mail_mail_id = fields.Many2one('mail.mail', string='Mail Record')
|
||||
|
||||
@api.depends('template_id', 'partner_id', 'sent_date', 'status')
|
||||
def _compute_display_name(self):
|
||||
trigger_labels = dict(self._fields['trigger_event'].selection)
|
||||
for rec in self:
|
||||
bits = []
|
||||
label = (
|
||||
rec.template_id.display_name
|
||||
or trigger_labels.get(rec.trigger_event)
|
||||
or 'Notification'
|
||||
)
|
||||
bits.append(label)
|
||||
if rec.partner_id:
|
||||
bits.append('→ %s' % rec.partner_id.display_name)
|
||||
if rec.sent_date:
|
||||
bits.append(rec.sent_date.strftime('%Y-%m-%d %H:%M'))
|
||||
rec.display_name = ' '.join(bits)
|
||||
|
||||
Reference in New Issue
Block a user