From 988e7690736be038dea7c52f3ecd4797fa793366 Mon Sep 17 00:00:00 2001 From: "Julien (juc) Castiaux" Date: Tue, 12 Feb 2019 15:38:40 +0000 Subject: [PATCH] [FIX] mail: non translated field when posting emails from crons 1) Configure both an incoming mail server and an outgoing one. 2) Install CRM. 3) Create a sale team, use the incoming mail address as mail alias. 4) Add a user with a valid email as follower of that team in the chatter. 5) Enable developer mode, become super user via the developer tools. 6) Change the language of the super user to french. 7) You may want to modify the default gather/post time interval. to receive/post email more regulary in the scheduled action. 8) Using an external mail client, send a mail to the incoming mail address. 9) Let the two scheduled actions run by themselves. 10) The mail sent to the user has the "Lead/Opportunity" in english wheras the rest of the email is in french. opw-1917993 closes odoo/odoo#31034 --- addons/mail/models/mail_thread.py | 4 +++- addons/test_mail/tests/test_performance.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 2965d4dad7a..9f76813eac2 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -742,7 +742,9 @@ class MailThread(models.AbstractModel): access_link = self._notify_get_action_link('view') if message.model: - model_name = self.env['ir.model']._get(message.model).display_name + model = self.env['ir.model'].with_context( + lang=self.env.context.get('lang', self.env.user.lang)) + model_name = model._get(message.model).display_name view_title = _('View %s') % model_name else: view_title = _('View') diff --git a/addons/test_mail/tests/test_performance.py b/addons/test_mail/tests/test_performance.py index f96a9f0f974..2d45899f142 100644 --- a/addons/test_mail/tests/test_performance.py +++ b/addons/test_mail/tests/test_performance.py @@ -265,7 +265,7 @@ class TestAdvMailPerformance(TransactionCase): def test_message_post_one_email_notification(self): record = self.env['mail.test.simple'].create({'name': 'Test'}) - with self.assertQueryCount(__system__=51, emp=71): # com runbot: 51 - 71 // test_mail only: 48 - 68 + with self.assertQueryCount(__system__=52, emp=72): # com runbot: 52 - 72 // test_mail only: 48 - 68 record.message_post( body='

Test Post Performances with an email ping

', partner_ids=self.customer.ids,