Skip to content
Snippets Groups Projects
Commit 7b22be48 authored by Nans Lefebvre's avatar Nans Lefebvre
Browse files

[FIX] account: restore standard composer behaviour when sending unique mails


Fine-tuning of commit 5621ae3d.
While it focused on fixing the 'mass_mail' mode,
it forgot to keep the correct behaviour for the case where only one mail is sent.
In the latter case, it is typical to overwrite the template values, especially
for the body, before sending the mail.
In that case, applying the onchange on the templates overwrites the user input.

Note that in the case where the template is undefined it would set the composer
values to empty ones; while standard use would not allow in mass mail to both
send content and have no template, it could be done via a customisation.

opw 2041631

closes odoo/odoo#35164

Signed-off-by: default avatarNans Lefebvre (len) <len@odoo.com>
parent 6a592240
Branches
Tags
No related merge requests found
......@@ -84,15 +84,18 @@ class AccountInvoiceSend(models.TransientModel):
# This should ideally be fixed in mail_compose_message, so when a fix is made there this whole commit should be reverted.
# basically self.body (which could be manually edited) extracts self.template_id,
# which is then not translated for each customer.
active_ids = self.env.context.get('active_ids', self.res_id)
active_records = self.env[self.model].browse(active_ids)
langs = active_records.mapped('partner_id.lang')
default_lang = self.env.context.get('lang', 'en_US')
for lang in (set(langs) or [default_lang]):
active_ids_lang = active_records.filtered(lambda r: r.partner_id.lang == lang).ids
self_lang = self.with_context(active_ids=active_ids_lang, lang=lang)
self_lang.onchange_template_id()
self_lang._send_email()
if self.composition_mode == 'mass_mail' and self.template_id:
active_ids = self.env.context.get('active_ids', self.res_id)
active_records = self.env[self.model].browse(active_ids)
langs = active_records.mapped('partner_id.lang')
default_lang = self.env.context.get('lang', 'en_US')
for lang in (set(langs) or [default_lang]):
active_ids_lang = active_records.filtered(lambda r: r.partner_id.lang == lang).ids
self_lang = self.with_context(active_ids=active_ids_lang, lang=lang)
self_lang.onchange_template_id()
self_lang._send_email()
else:
self._send_email()
if self.is_print:
return self._print_document()
return {'type': 'ir.actions.act_window_close'}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment