summaryrefslogtreecommitdiff
path: root/addons/account/wizard/account_invoice_send.py
diff options
context:
space:
mode:
Diffstat (limited to 'addons/account/wizard/account_invoice_send.py')
-rw-r--r--addons/account/wizard/account_invoice_send.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/addons/account/wizard/account_invoice_send.py b/addons/account/wizard/account_invoice_send.py
index 812ed0ec297..18701888538 100644
--- a/addons/account/wizard/account_invoice_send.py
+++ b/addons/account/wizard/account_invoice_send.py
@@ -86,7 +86,22 @@ class AccountInvoiceSend(models.TransientModel):
@api.multi
def send_and_print_action(self):
self.ensure_one()
- self._send_email()
+ # Send the mails in the correct language by splitting the ids per lang.
+ # 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.
+ 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'}