diff --git a/mail_no_reply/__manifest__.py b/mail_no_reply/__manifest__.py index 57048bb..ff73dfb 100644 --- a/mail_no_reply/__manifest__.py +++ b/mail_no_reply/__manifest__.py @@ -14,6 +14,7 @@ ], "data": [ "views/mail_compose_message.xml", + "views/mail_template.xml", "views/res_company.xml", "views/res_config.xml", ], diff --git a/mail_no_reply/models/__init__.py b/mail_no_reply/models/__init__.py index 4144dd0..0cd150c 100644 --- a/mail_no_reply/models/__init__.py +++ b/mail_no_reply/models/__init__.py @@ -1,3 +1,4 @@ from . import res_company from . import mail_template +from . import mail_compose_message from . import res_config_settings diff --git a/mail_no_reply/models/mail_compose_message.py b/mail_no_reply/models/mail_compose_message.py new file mode 100644 index 0000000..4db4709 --- /dev/null +++ b/mail_no_reply/models/mail_compose_message.py @@ -0,0 +1,15 @@ +from odoo import api, fields, models + + +class MailComposeMessage(models.TransientModel): + _inherit = "mail.compose.message" + + active_no_reply = fields.Boolean(string="Use no-reply email") + + @api.onchange("active_no_reply") + def _onchange_active_no_reply(self): + template_id = self.env.context.get("default_template_id") + if template_id: + mail_template = self.env["mail.template"].browse(template_id) + if mail_template: + mail_template.active_no_reply = self.active_no_reply diff --git a/mail_no_reply/models/mail_template.py b/mail_no_reply/models/mail_template.py index 82c59ca..a91e22a 100644 --- a/mail_no_reply/models/mail_template.py +++ b/mail_no_reply/models/mail_template.py @@ -8,12 +8,9 @@ class MailTemplate(models.Model): @api.onchange("active_no_reply") def _onchange_active_no_reply(self): - standard_email_from = ( - "{{ (object.company_id.email_formatted or user.email_formatted) }}" - ) if self.active_no_reply and self.env.user.company_id.email_no_reply: self.email_from = self.env.user.company_id.email_no_reply self.reply_to = self.env.user.company_id.email_no_reply if not self.active_no_reply: - self.email_from = standard_email_from + self.email_from = False self.reply_to = False diff --git a/mail_no_reply/views/mail_compose_message.xml b/mail_no_reply/views/mail_compose_message.xml index e23637c..99d4ab1 100644 --- a/mail_no_reply/views/mail_compose_message.xml +++ b/mail_no_reply/views/mail_compose_message.xml @@ -1,10 +1,10 @@ - + mail compose message form mail no reply - mail.template - + mail.compose.message + - + diff --git a/mail_no_reply/views/mail_template.xml b/mail_no_reply/views/mail_template.xml new file mode 100644 index 0000000..c9300ca --- /dev/null +++ b/mail_no_reply/views/mail_template.xml @@ -0,0 +1,12 @@ + + + mail template form mail no reply + mail.template + + + + + + + +