summaryrefslogtreecommitdiff
path: root/addons/mail/models/mail_alias.py
diff options
context:
space:
mode:
authorryv-odoo <ryv@odoo.com>2019-11-28 15:18:33 +0000
committerThibault Delavallée <tde@odoo.com>2020-04-17 06:52:09 +0000
commit186cfb5ebd35d572d0f635cd7975de7cff0d1055 (patch)
treeee135e1a5b8b68bc74b44149440bb776956a54ee /addons/mail/models/mail_alias.py
parent7cfd364db54e88970ef51c798df3bd4df44222b3 (diff)
[REF] mail: make alias mixin multi-enabled
Purpose of this commit is to allow multi-create in alias mixin by correctly creating / updating aliases in batch. Task ID 1919277 Community PR odoo/odoo#41160 Enterprise PR odoo/enterprise#6983 Upgrade PR odoo/upgrade#872 Co-Authored-By: Rémy Voet <ryv@odoo.com> Co-Authored-By: Thibault Delavallée <tde@odoo.com>
Diffstat (limited to 'addons/mail/models/mail_alias.py')
-rw-r--r--addons/mail/models/mail_alias.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/addons/mail/models/mail_alias.py b/addons/mail/models/mail_alias.py
index ed36d8a3a63..e66cf303b98 100644
--- a/addons/mail/models/mail_alias.py
+++ b/addons/mail/models/mail_alias.py
@@ -27,6 +27,9 @@ class Alias(models.Model):
_rec_name = 'alias_name'
_order = 'alias_model_id, alias_name'
+ def _default_alias_domain(self):
+ return self.env["ir.config_parameter"].sudo().get_param("mail.catchall.domain")
+
alias_name = fields.Char('Alias Name', copy=False, help="The name of the email alias, e.g. 'jobs' if you want to catch emails for <jobs@example.odoo.com>")
alias_model_id = fields.Many2one('ir.model', 'Aliased Model', required=True, ondelete="cascade",
help="The model (Odoo Document Kind) to which this alias "
@@ -48,8 +51,7 @@ class Alias(models.Model):
'Record Thread ID',
help="Optional ID of a thread (record) to which all incoming messages will be attached, even "
"if they did not reply to it. If set, this will disable the creation of new records completely.")
- alias_domain = fields.Char('Alias domain', compute='_get_alias_domain',
- default=lambda self: self.env["ir.config_parameter"].sudo().get_param("mail.catchall.domain"))
+ alias_domain = fields.Char('Alias domain', compute='_compute_alias_domain', default=_default_alias_domain)
alias_parent_model_id = fields.Many2one(
'ir.model', 'Parent Model',
help="Parent model holding the alias. The model holding the alias reference "
@@ -73,8 +75,8 @@ class Alias(models.Model):
('alias_unique', 'UNIQUE(alias_name)', 'Unfortunately this email alias is already used, please choose a unique one')
]
- def _get_alias_domain(self):
- alias_domain = self.env["ir.config_parameter"].sudo().get_param("mail.catchall.domain")
+ def _compute_alias_domain(self):
+ alias_domain = self._default_alias_domain()
for record in self:
record.alias_domain = alias_domain