diff options
| author | Thibault Delavallée <tde@odoo.com> | 2018-02-14 13:07:25 +0100 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2018-05-07 10:58:54 +0200 |
| commit | 282733cf8df7bfe7cae17fd726d1caf759690169 (patch) | |
| tree | 4e0802c19a7114af7ba5944861b0812cf2ad2501 /addons/mail/wizard/mail_compose_message.py | |
| parent | 6cb5052e856a83914611898cd86d810e3ef15148 (diff) | |
[REF] mail: make notification methods semi-generic
mail.thread mixing class defines several methods used in notification process
that are not specific to mail.thread enabled models. It means some models
could override it while some other models do not even have a direct access
to that method.
When calling those methods we have to manually check for method being
available on a record or call a default implementation from mail.thread
even if the model does not inherit from the mixin.
In this commit we propose to hide this check in generic wrappers located
in mail.thread class. It checks for method existence on record and call
the model-specific implementation or falls back on standard behavior. It
allows to be sure the right method is called.
Functionally behavior should stay globally the same. However when updating
some addons code has been updated. Previous code could lead to records not
having correct alias which should not be the case anymore. This commit is
linked to task ID 47934.
Diffstat (limited to 'addons/mail/wizard/mail_compose_message.py')
| -rw-r--r-- | addons/mail/wizard/mail_compose_message.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 4cc06574ec4..91718f21f8a 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -278,8 +278,8 @@ class MailComposer(models.TransientModel): # compute alias-based reply-to in batch reply_to_value = dict.fromkeys(res_ids, None) if mass_mail_mode and not self.no_auto_thread: - # reply_to_value = self.env['mail.thread'].with_context(thread_model=self.model).browse(res_ids)._notify_get_reply_to(default=self.email_from) - reply_to_value = self.env['mail.thread'].with_context(thread_model=self.model)._notify_get_reply_to(res_ids, default=self.email_from) + records = self.env[self.model].browse(res_ids) + reply_to_value = self.env['mail.thread']._notify_get_reply_to_on_records(default=self.email_from, records=records) for res_id in res_ids: # static wizard (mail.message) values @@ -299,8 +299,7 @@ class MailComposer(models.TransientModel): # mass mailing: rendering override wizard static values if mass_mail_mode and self.model: - if self.model in self.env and hasattr(self.env[self.model], '_notify_specific_email_values'): - mail_values.update(self.env[self.model].browse(res_id)._notify_specific_email_values(False)) + mail_values.update(self.env['mail.thread']._notify_specific_email_values_on_records(False, records=self.env[self.model].browse(res_id))) # keep a copy unless specifically requested, reset record name (avoid browsing records) mail_values.update(notification=not self.auto_delete_message, model=self.model, res_id=res_id, record_name=False) # auto deletion of mail_mail |
