Replace em-dashes and en-dashes with hyphens across 789 shipped source files (py/xml/js/scss) so the delivered module reads as human-written; em-dashes had become a recognizable AI-generated tell. Internal .md dev notes are excluded. The WO-sticker mojibake strippers keep their dash search targets (now written — / –). No logic changes: comments and display strings only; validated with py_compile + lxml parse. Rewrite the 7 customer notification emails to be intake-neutral (ship-in / drop-off / pickup) and repair-aware, and fix the Shipped email documents line (packing slip vs bill of lading; certificate only when issued). Subjects use a hyphen separator. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
67 lines
2.6 KiB
Python
67 lines
2.6 KiB
Python
# -*- 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 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()
|
|
|
|
# NOTE: we intentionally do NOT override action_quotation_send to
|
|
# fire the quote_sent trigger. action_quotation_send returns a
|
|
# compose-dialog action synchronously - if we dispatch here the
|
|
# email is already sent by the time the user sees the dialog and
|
|
# decides to Cancel.
|
|
#
|
|
# The Send button itself IS the manual-send path; Odoo's compose
|
|
# dialog (populated with our FP: Quotation Sent template via the
|
|
# _find_mail_template override) handles the send-or-cancel choice
|
|
# cleanly. If an auto-quote-sent notification is ever desired,
|
|
# wire it from a cron job that scans SOs that just transitioned
|
|
# from draft → sent, not from the button handler.
|
|
|
|
def action_confirm(self):
|
|
res = super().action_confirm()
|
|
Dispatch = self.env['fp.notification.template']
|
|
for order in self:
|
|
Dispatch._dispatch(
|
|
'so_confirmed', order, order.partner_id, sale_order=order,
|
|
)
|
|
return res
|