From 3a9da42eff8a7238394a5052418b606527a7ac6d Mon Sep 17 00:00:00 2001 From: Nuno Silva Date: Thu, 25 Feb 2021 14:30:27 +0000 Subject: [PATCH] [FIX] mail: use current user company in notification When sending a notification, the company used is: - company_id of current record or if not available, - company_id of author or if no author, - company_id of user This can seem unexpected if the author is the current user and the company_id of our user is different than the current company switcher company. With this changeset: the company used is: - company_id of current record or if not available, - company_id of author if author is different than user or, - current company in company switcher or if not, - company_id of user opw-2472622 closes odoo/odoo#73031 X-original-commit: 3f61d9e2dadf47d211ed078b36e9f3a416bbbff0 Signed-off-by: Nicolas Lempereur (nle) --- addons/mail/models/mail_thread.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 86f426c8335..0b1a9ca5fdf 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -2326,7 +2326,9 @@ class MailThread(models.AbstractModel): if add_sign: signature = "

--
%s

" % author.name - company = self.company_id.sudo() if self and 'company_id' in self else user.company_id + # use company switcher company if author is current user + user_company = self.env.company if self.env.user == user else user.company_id + company = self.company_id.sudo() if self and 'company_id' in self else user_company if company.website: website_url = 'http://%s' % company.website if not company.website.lower().startswith(('http:', 'https:')) else company.website else: