This commit is contained in:
gsinghpal
2026-04-20 01:16:12 -04:00
parent 8217bb0ff6
commit 54e56ed0e6
39 changed files with 5600 additions and 1131 deletions

View File

@@ -9,6 +9,24 @@ from odoo import models
class AccountMove(models.Model):
_inherit = 'account.move'
def _get_mail_template(self):
"""Prefer the Fusion Plating-branded invoice template over Odoo default.
Called by the account.move.send wizard when the user clicks
"Send" on an invoice. Override returns our
fp_mail_template_invoice_posted (which attaches the branded
Invoice PDF) for out_invoice moves. Credit notes / self-billing
fall back to Odoo's built-in templates.
"""
if all(m.move_type == 'out_invoice' for m in self):
tpl = self.env.ref(
'fusion_plating_notifications.fp_mail_template_invoice_posted',
raise_if_not_found=False,
)
if tpl:
return tpl
return super()._get_mail_template()
def action_post(self):
res = super().action_post()
Dispatch = self.env['fp.notification.template']

View File

@@ -9,6 +9,40 @@ from odoo import models
class SaleOrder(models.Model):
_inherit = 'sale.order'
def _find_mail_template(self):
"""Prefer Fusion Plating-branded templates over Odoo defaults.
Called by sale.order.action_quotation_send (the "Send" button on
both quotations and confirmed orders) to resolve the template
the composer pre-selects.
Override returns:
- state in ('draft', 'sent') -> fp_mail_template_quote_sent
(attaches Quotation PDF)
- state == 'sale' or 'done' -> fp_mail_template_so_confirmed
(attaches Acknowledgement PDF)
Falls back to Odoo's default template if ours can't be resolved
(e.g. fusion_plating_reports not installed, or template record
missing).
"""
self.ensure_one()
ref = self.env.ref
if self.env.context.get('proforma'):
return super()._find_mail_template()
fp_tpl = False
if self.state in ('draft', 'sent'):
fp_tpl = ref(
'fusion_plating_notifications.fp_mail_template_quote_sent',
raise_if_not_found=False,
)
elif self.state in ('sale', 'done'):
fp_tpl = ref(
'fusion_plating_notifications.fp_mail_template_so_confirmed',
raise_if_not_found=False,
)
return fp_tpl or super()._find_mail_template()
def action_quotation_send(self):
"""Fire the quote_sent trigger when a quotation is emailed."""
res = super().action_quotation_send()