summaryrefslogtreecommitdiff
path: root/addons/mass_mailing/models/mailing.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2019-04-24 10:25:09 +0000
committerThibault Delavallée <tde@odoo.com>2019-11-29 13:35:14 +0000
commit1838191eece59051805862ed6ce914bf5e5d1efb (patch)
tree75955be7412a59bd7463bf4b61116b5711141352 /addons/mass_mailing/models/mailing.py
parentb9a22d2f24e587894c12bf7ad289fcddcea8a823 (diff)
[REF] mail, various: improve mail creation calls, notably author and email from default computation
Purpose of this commit is to correctly compute author_id and email_from in mail_message and mail_mail as they depends from each other. Moreover it is a good idea in various flows to specify email and author when giving creation values to avoid default computation that is not always guaranteed to be accurate notably when involving super user. Mail message creation could lead to desynchronized values between author and email_from. This is improved with this commit by correctly inheriting from default_get and computing both of them at the same time instead of having two default values. Indeed they depend on each other. Same thing is done for mail composer. Mail Thread offers a tool method to find email_from / author_id based on having one of those values or current user and it is called whenever necessary. Some calls to mail template send_mail are also cleaned. Task ID 1853147 PR #32243
Diffstat (limited to 'addons/mass_mailing/models/mailing.py')
-rw-r--r--addons/mass_mailing/models/mailing.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/mass_mailing/models/mailing.py b/addons/mass_mailing/models/mailing.py
index cd098b3a347..999b3f824b0 100644
--- a/addons/mass_mailing/models/mailing.py
+++ b/addons/mass_mailing/models/mailing.py
@@ -69,7 +69,7 @@ class MassMailing(models.Model):
active = fields.Boolean(default=True, tracking=True)
subject = fields.Char('Subject', help='Subject of emails to send', required=True, translate=True)
email_from = fields.Char(string='Send From', required=True,
- default=lambda self: self.env['mail.message']._get_default_from())
+ default=lambda self: self.env.user.email_formatted)
sent_date = fields.Datetime(string='Sent Date', copy=False)
schedule_date = fields.Datetime(string='Scheduled for', tracking=True)
# don't translate 'body_arch', the translations are only on 'body_html'
@@ -92,7 +92,7 @@ class MassMailing(models.Model):
reply_to_mode = fields.Selection(
[('thread', 'Recipient Followers'), ('email', 'Specified Email Address')], string='Reply-To Mode', required=True)
reply_to = fields.Char(string='Reply To', help='Preferred Reply-To Address',
- default=lambda self: self.env['mail.message']._get_default_from())
+ default=lambda self: self.env.user.email_formatted)
# recipients
mailing_model_real = fields.Char(compute='_compute_model', string='Recipients Real Model', default='mailing.contact', required=True)
mailing_model_id = fields.Many2one('ir.model', string='Recipients Model', domain=[('model', 'in', MASS_MAILING_BUSINESS_MODELS)],