diff --git a/addons/hr/data/hr_data.xml b/addons/hr/data/hr_data.xml index 60601583cd1..2e7fca012b7 100644 --- a/addons/hr/data/hr_data.xml +++ b/addons/hr/data/hr_data.xml @@ -60,44 +60,6 @@ ])]"/> - - HR: mailgateway unknown employee bounce - - Your document has not been created - ${user.email_formatted | safe} - ${ctx['email_to']|safe} - - - - -
- - - - - -
- - -
-
- Hi,
- Your document has not been created because your email address is not recognized. Please send emails with the email address recorded on your employee information, or contact your HR manager. -
-
-
-
- - -
- Powered by Odoo -
-
-
- ${user.lang} - -
- hr.hr_presence_control_login True diff --git a/addons/hr/models/mail_alias.py b/addons/hr/models/mail_alias.py index c224d21df07..6a363221943 100644 --- a/addons/hr/models/mail_alias.py +++ b/addons/hr/models/mail_alias.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import fields, models, tools +from odoo import fields, models, tools, _ class Alias(models.Model): @@ -9,8 +9,16 @@ class Alias(models.Model): alias_contact = fields.Selection(selection_add=[('employees', 'Authenticated Employees')]) + def _get_alias_bounced_body_fallback(self, message_dict): + if self.alias_contact == 'employees': + return _("""Hi,
+Your document has not been created because your email address is not recognized.
+Please send emails with the email address recorded on your employee information, or contact your HR manager.""") + else: + return super(Alias, self)._get_alias_bounced_body_fallback(message_dict) -class MailAlias(models.AbstractModel): + +class AliasMixin(models.AbstractModel): _inherit = 'mail.alias.mixin' def _alias_check_contact_on_record(self, record, message, message_dict, alias): @@ -21,9 +29,6 @@ class MailAlias(models.AbstractModel): if not employee: employee = self.env['hr.employee'].search([('user_id.email', 'ilike', email_address)], limit=1) if not employee: - return { - 'error_message': 'restricted to employees', - 'error_template': self.env.ref('hr.mail_template_data_unknown_employee_email_address').body_html, - } + return _('restricted to employees') return True - return super(MailAlias, self)._alias_check_contact_on_record(record, message, message_dict, alias) + return super(AliasMixin, self)._alias_check_contact_on_record(record, message, message_dict, alias) diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index a83cafbbc8d..3e0c6ca6b37 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -363,6 +363,12 @@
+ + +