feat(notifications): module scaffold + models + mail template seed data
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
6
fusion-plating/fusion_plating_notifications/__init__.py
Normal file
6
fusion-plating/fusion_plating_notifications/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
# Part of the Fusion Plating product family.
|
||||
|
||||
from . import models
|
||||
44
fusion-plating/fusion_plating_notifications/__manifest__.py
Normal file
44
fusion-plating/fusion_plating_notifications/__manifest__.py
Normal file
@@ -0,0 +1,44 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
# Part of the Fusion Plating product family.
|
||||
|
||||
{
|
||||
'name': 'Fusion Plating — Notifications',
|
||||
'version': '19.0.1.0.0',
|
||||
'category': 'Manufacturing/Plating',
|
||||
'summary': 'Auto-email notifications at workflow milestones with configurable templates and audit log.',
|
||||
'description': """
|
||||
Fusion Plating — Notifications
|
||||
================================
|
||||
|
||||
Automated email notifications triggered at key workflow events:
|
||||
SO confirmation, parts received, invoice posted, and more.
|
||||
""",
|
||||
'author': 'Nexa Systems Inc.',
|
||||
'website': 'https://www.nexasystems.ca',
|
||||
'maintainer': 'Nexa Systems Inc.',
|
||||
'support': 'support@nexasystems.ca',
|
||||
'license': 'OPL-1',
|
||||
'price': 0.00,
|
||||
'currency': 'CAD',
|
||||
'depends': [
|
||||
'fusion_plating_configurator',
|
||||
'fusion_plating_receiving',
|
||||
'fusion_plating_invoicing',
|
||||
'sale_management',
|
||||
'account',
|
||||
'mail',
|
||||
],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'data/mail_template_data.xml',
|
||||
'data/fp_notification_template_data.xml',
|
||||
'views/fp_notification_template_views.xml',
|
||||
'views/fp_notification_log_views.xml',
|
||||
'views/fp_notifications_menu.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'application': False,
|
||||
'auto_install': False,
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo noupdate="1">
|
||||
|
||||
<record id="fp_notif_so_confirmed" model="fp.notification.template">
|
||||
<field name="name">Order Confirmation</field>
|
||||
<field name="trigger_event">so_confirmed</field>
|
||||
<field name="mail_template_id" ref="fp_mail_template_so_confirmed"/>
|
||||
<field name="active" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record id="fp_notif_parts_received" model="fp.notification.template">
|
||||
<field name="name">Parts Received</field>
|
||||
<field name="trigger_event">parts_received</field>
|
||||
<field name="mail_template_id" ref="fp_mail_template_parts_received"/>
|
||||
<field name="active" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record id="fp_notif_invoice_posted" model="fp.notification.template">
|
||||
<field name="name">Invoice Posted</field>
|
||||
<field name="trigger_event">invoice_posted</field>
|
||||
<field name="mail_template_id" ref="fp_mail_template_invoice_posted"/>
|
||||
<field name="active" eval="True"/>
|
||||
<field name="attach_invoice" eval="True"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo noupdate="1">
|
||||
|
||||
<record id="fp_mail_template_so_confirmed" model="mail.template">
|
||||
<field name="name">FP: Order Confirmation</field>
|
||||
<field name="model_id" ref="sale.model_sale_order"/>
|
||||
<field name="subject">Order Confirmation — {{ object.name }}</field>
|
||||
<field name="email_from">{{ (object.company_id.email or user.email) }}</field>
|
||||
<field name="email_to">{{ object.partner_id.email }}</field>
|
||||
<field name="body_html" type="html">
|
||||
<p>Dear {{ object.partner_id.name }},</p>
|
||||
<p>Your order <strong>{{ object.name }}</strong> has been confirmed.</p>
|
||||
<p>We will notify you when your parts have been received at our facility.</p>
|
||||
<p>Thank you for your business.</p>
|
||||
<p>— EN Technologies Inc.</p>
|
||||
</field>
|
||||
<field name="auto_delete" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record id="fp_mail_template_parts_received" model="mail.template">
|
||||
<field name="name">FP: Parts Received</field>
|
||||
<field name="model_id" eval="env['ir.model']._get_id('fp.receiving')"/>
|
||||
<field name="subject">Parts Received — {{ object.name }}</field>
|
||||
<field name="email_from">{{ (object.sale_order_id.company_id.email or user.email) }}</field>
|
||||
<field name="email_to">{{ object.partner_id.email }}</field>
|
||||
<field name="body_html" type="html">
|
||||
<p>Dear {{ object.partner_id.name }},</p>
|
||||
<p>We have received your parts for order <strong>{{ object.sale_order_id.name }}</strong>.</p>
|
||||
<p>Quantity received: {{ object.received_qty }}</p>
|
||||
<p>Your parts are now in our production queue. We will keep you updated on progress.</p>
|
||||
<p>— EN Technologies Inc.</p>
|
||||
</field>
|
||||
<field name="auto_delete" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record id="fp_mail_template_invoice_posted" model="mail.template">
|
||||
<field name="name">FP: Invoice Notification</field>
|
||||
<field name="model_id" ref="account.model_account_move"/>
|
||||
<field name="subject">Invoice {{ object.name }} — EN Technologies</field>
|
||||
<field name="email_from">{{ (object.company_id.email or user.email) }}</field>
|
||||
<field name="email_to">{{ object.partner_id.email }}</field>
|
||||
<field name="body_html" type="html">
|
||||
<p>Dear {{ object.partner_id.name }},</p>
|
||||
<p>Please find your invoice <strong>{{ object.name }}</strong> for amount <strong>{{ object.amount_total }}</strong>.</p>
|
||||
<p>Thank you for your business.</p>
|
||||
<p>— EN Technologies Inc.</p>
|
||||
</field>
|
||||
<field name="auto_delete" eval="True"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
# Part of the Fusion Plating product family.
|
||||
|
||||
from . import fp_notification_template
|
||||
from . import fp_notification_log
|
||||
from . import sale_order
|
||||
from . import fp_receiving
|
||||
from . import account_move
|
||||
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
# Part of the Fusion Plating product family.
|
||||
|
||||
# Placeholder — implemented in Task 3.
|
||||
@@ -0,0 +1,39 @@
|
||||
# -*- 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 fields, models
|
||||
|
||||
TRIGGER_EVENTS = [
|
||||
('so_confirmed', 'Order Confirmed'),
|
||||
('parts_received', 'Parts Received'),
|
||||
('mo_complete', 'Manufacturing Complete'),
|
||||
('shipment', 'Shipment (Carrier)'),
|
||||
('delivery', 'Delivery (Local)'),
|
||||
('invoice_posted', 'Invoice Posted'),
|
||||
('deposit_created', 'Deposit Required'),
|
||||
]
|
||||
|
||||
|
||||
class FpNotificationLog(models.Model):
|
||||
"""Audit trail for sent notifications."""
|
||||
_name = 'fp.notification.log'
|
||||
_description = 'Fusion Plating — Notification Log'
|
||||
_order = 'sent_date desc, id desc'
|
||||
|
||||
template_id = fields.Many2one(
|
||||
'fp.notification.template', string='Template', ondelete='set null',
|
||||
)
|
||||
trigger_event = fields.Selection(TRIGGER_EVENTS, string='Trigger Event')
|
||||
sale_order_id = fields.Many2one('sale.order', string='Sale Order')
|
||||
partner_id = fields.Many2one('res.partner', string='Customer')
|
||||
sent_date = fields.Datetime(string='Sent Date', default=fields.Datetime.now)
|
||||
recipient_email = fields.Char(string='Recipient Email')
|
||||
attachment_names = fields.Text(string='Attachments')
|
||||
status = fields.Selection(
|
||||
[('sent', 'Sent'), ('failed', 'Failed')],
|
||||
string='Status', default='sent',
|
||||
)
|
||||
error_message = fields.Text(string='Error Message')
|
||||
mail_mail_id = fields.Many2one('mail.mail', string='Mail Record')
|
||||
@@ -0,0 +1,51 @@
|
||||
# -*- 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 fields, models
|
||||
|
||||
TRIGGER_EVENTS = [
|
||||
('so_confirmed', 'Order Confirmed'),
|
||||
('parts_received', 'Parts Received'),
|
||||
('mo_complete', 'Manufacturing Complete'),
|
||||
('shipment', 'Shipment (Carrier)'),
|
||||
('delivery', 'Delivery (Local)'),
|
||||
('invoice_posted', 'Invoice Posted'),
|
||||
('deposit_created', 'Deposit Required'),
|
||||
]
|
||||
|
||||
|
||||
class FpNotificationTemplate(models.Model):
|
||||
"""Configurable notification wrapper.
|
||||
|
||||
Each record maps a trigger event to a mail.template and controls
|
||||
whether the notification fires and what attachments are included.
|
||||
"""
|
||||
_name = 'fp.notification.template'
|
||||
_description = 'Fusion Plating — Notification Template'
|
||||
_order = 'trigger_event'
|
||||
|
||||
name = fields.Char(string='Template Name', required=True)
|
||||
trigger_event = fields.Selection(
|
||||
TRIGGER_EVENTS, string='Trigger Event', required=True,
|
||||
)
|
||||
mail_template_id = fields.Many2one(
|
||||
'mail.template', string='Email Template',
|
||||
help='The Odoo mail template used to render and send the email.',
|
||||
)
|
||||
active = fields.Boolean(string='Active', default=True)
|
||||
attach_coc = fields.Boolean(string='Attach CoC')
|
||||
attach_thickness_report = fields.Boolean(string='Attach Thickness Report')
|
||||
attach_invoice = fields.Boolean(string='Attach Invoice')
|
||||
attach_packing_list = fields.Boolean(string='Attach Packing List')
|
||||
attach_pod = fields.Boolean(string='Attach Proof of Delivery')
|
||||
cc_internal_ids = fields.Many2many(
|
||||
'res.users', 'fp_notification_template_cc_rel',
|
||||
'template_id', 'user_id', string='CC (Internal)',
|
||||
)
|
||||
|
||||
_sql_constraints = [
|
||||
('fp_notification_trigger_uniq', 'unique(trigger_event)',
|
||||
'Only one notification template per trigger event.'),
|
||||
]
|
||||
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
# Part of the Fusion Plating product family.
|
||||
|
||||
# Placeholder — implemented in Task 3.
|
||||
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
# Part of the Fusion Plating product family.
|
||||
|
||||
# Placeholder — implemented in Task 3.
|
||||
@@ -0,0 +1,6 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_fp_notification_template_operator,fp.notification.template.operator,model_fp_notification_template,fusion_plating.group_fusion_plating_operator,1,0,0,0
|
||||
access_fp_notification_template_manager,fp.notification.template.manager,model_fp_notification_template,fusion_plating.group_fusion_plating_manager,1,1,1,1
|
||||
access_fp_notification_log_operator,fp.notification.log.operator,model_fp_notification_log,fusion_plating.group_fusion_plating_operator,1,0,0,0
|
||||
access_fp_notification_log_supervisor,fp.notification.log.supervisor,model_fp_notification_log,fusion_plating.group_fusion_plating_supervisor,1,1,1,0
|
||||
access_fp_notification_log_manager,fp.notification.log.manager,model_fp_notification_log,fusion_plating.group_fusion_plating_manager,1,1,1,1
|
||||
|
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
</odoo>
|
||||
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
</odoo>
|
||||
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user