[FIX] mail: translate assignation msg in recipient lang
Before this commit, when assigning a user onto a record, through the field user_id, the email was sent in the current user's language After this commit, it is sent in the partner's language OPW 2060898 closes odoo/odoo#38142 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
committed by
Lucas Perais (lpe)
parent
383b1d873f
commit
2b830e5d41
@@ -2870,7 +2870,9 @@ class MailThread(models.AbstractModel):
|
||||
for pid, sids, template in res:
|
||||
new_partners.setdefault(pid, sids)
|
||||
if template:
|
||||
notify_data.setdefault(template, list()).append(pid)
|
||||
partner = self.env['res.partner'].browse(pid)
|
||||
lang = partner.lang if partner else None
|
||||
notify_data.setdefault((template, lang), list()).append(pid)
|
||||
|
||||
self.env['mail.followers']._insert_followers(
|
||||
self._name, self.ids,
|
||||
@@ -2879,8 +2881,8 @@ class MailThread(models.AbstractModel):
|
||||
check_existing=True, existing_policy='skip')
|
||||
|
||||
# notify people from auto subscription, for example like assignation
|
||||
for template, pids in notify_data.items():
|
||||
self._message_auto_subscribe_notify(pids, template)
|
||||
for (template, lang), pids in notify_data.items():
|
||||
self.with_context(lang=lang)._message_auto_subscribe_notify(pids, template)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ class TestAdvMailPerformance(BaseMailPerformance):
|
||||
def test_message_assignation_email(self):
|
||||
self.user_test.write({'notification_type': 'email'})
|
||||
record = self.env['mail.test.track'].create({'name': 'Test'})
|
||||
with self.assertQueryCount(__system__=39, emp=40):
|
||||
with self.assertQueryCount(__system__=40, emp=41):
|
||||
record.write({
|
||||
'user_id': self.user_test.id,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user