feat(notifications): Sub 6 — contact profiles + communication routing
Five new boolean flags on res.partner applied to CHILD contacts: x_fc_receives_certs, _qc, _quotes_so, _invoices, and _is_global_contact. Single resolver helper res.partner._fp_resolve_notification_recipients (stream, delivery_location=None) walks location contacts first then company contacts, returning emails for contacts that opted into the stream (or flagged themselves global). Falls back to partner.email when no contact opts in so existing customers keep their exact pre-Sub-6 routing. fp.notification.template._dispatch now maps each trigger event to a stream (so_confirmed→quotes_so, invoice_posted→invoices, shipped→ certs, etc.) and overrides the mail_template's email_to with the resolved list. fp.delivery passes its delivery_address_id so the shipped/CoC email routes through location-scoped contacts when they exist. Partner form gets a new "Communication Routing" tab on child contact forms with the 5 flags (hides the per-stream checkboxes when Global Contact is on, since it overrides them). fusion_plating_certificates → 19.0.4.0.0 (adds the flag fields) fusion_plating_notifications → 19.0.5.0.0 (+depends certificates) Smoke on entech: 11/11 assertions pass including per-stream routing, delivery-location scoping, zero-flag fallback, email-less skip, unknown-stream + global behaviour, and case-insensitive dedup. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -48,3 +48,42 @@ class ResPartner(models.Model):
|
||||
'thickness reading has been logged for the MO. Leave off '
|
||||
'for commercial customers.',
|
||||
)
|
||||
|
||||
# ---- Sub 6 — Per-contact communication routing -----------------------
|
||||
# These five flags live on CHILD contacts under a company partner.
|
||||
# When every contact under a company leaves them blank, the resolver
|
||||
# falls back to the company's own `email` — matching the pre-Sub-6
|
||||
# behaviour exactly. Admins opt in to per-contact routing by ticking
|
||||
# the relevant flag on each contact row.
|
||||
x_fc_receives_certs = fields.Boolean(
|
||||
string='Receives Certificates',
|
||||
default=False, tracking=True,
|
||||
help='This contact receives CoC PDFs, thickness reports, and '
|
||||
'other quality documents when a job ships.',
|
||||
)
|
||||
x_fc_receives_qc = fields.Boolean(
|
||||
string='Receives QC Alerts',
|
||||
default=False, tracking=True,
|
||||
help='This contact receives NCR, CAPA, quality-hold, and contract-'
|
||||
'review notifications.',
|
||||
)
|
||||
x_fc_receives_quotes_so = fields.Boolean(
|
||||
string='Receives Quotes & SOs',
|
||||
default=False, tracking=True,
|
||||
help='This contact receives quote sends, sale order acknowledgements, '
|
||||
'and order confirmations.',
|
||||
)
|
||||
x_fc_receives_invoices = fields.Boolean(
|
||||
string='Receives Invoices',
|
||||
default=False, tracking=True,
|
||||
help='This contact receives invoices, payment receipts, and '
|
||||
'dunning communications.',
|
||||
)
|
||||
x_fc_is_global_contact = fields.Boolean(
|
||||
string='Global Contact',
|
||||
default=False, tracking=True,
|
||||
help='Firehose. When set, this contact receives every outbound '
|
||||
'stream regardless of the per-stream flags above. Typical '
|
||||
'use: a primary account-manager contact who wants full '
|
||||
'visibility into everything the shop sends out.',
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user