From 4ac10f20c45a401161fd8714c808728ff4364dc2 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 18 Apr 2018 16:53:04 +0200 Subject: [PATCH] [FIX] account, purchase, sale: Wrong company displayed in the footer Steps to reproduce the bug: - Set a multi company environment with two company A and B - Set user admin in company A - Set user demo in company B - Create a PO with user demo - Send a RFQ Bug: The company of the admin user was displayed in the footer of the email. The function _notify called on res.parter model is called in sudo by the function _notify on mail.message model. The function render_template on mail.template model uses the user defined on self.env to render the template. So the user admin was always used. opw:1835647 --- .../data/email_template_data_invoice.xml | 2 +- addons/purchase/data/mail_template_data.xml | 17 +++++++++-------- addons/sale/data/mail_template_data.xml | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/addons/account/data/email_template_data_invoice.xml b/addons/account/data/email_template_data_invoice.xml index b012e8cbbf1..7701b1ce222 100644 --- a/addons/account/data/email_template_data_invoice.xml +++ b/addons/account/data/email_template_data_invoice.xml @@ -70,7 +70,7 @@ from ${object.company_id.name}. % set record = ctx.get('record') - % set company = record and record.company_id or user.company_id + % set company = record and record.company_id or ctx.get('company') diff --git a/addons/purchase/data/mail_template_data.xml b/addons/purchase/data/mail_template_data.xml index 35445697973..626da70daa9 100644 --- a/addons/purchase/data/mail_template_data.xml +++ b/addons/purchase/data/mail_template_data.xml @@ -86,6 +86,7 @@ from ${object.company_id.name}. + % set company = record and record.company_id or ctx.get('company')
@@ -101,7 +102,7 @@ from ${object.company_id.name}.
- ${user.company_id.name} + ${company.name}
@@ -127,16 +128,16 @@ from ${object.company_id.name}. diff --git a/addons/sale/data/mail_template_data.xml b/addons/sale/data/mail_template_data.xml index acae4ff8cc1..79e796b2c73 100644 --- a/addons/sale/data/mail_template_data.xml +++ b/addons/sale/data/mail_template_data.xml @@ -69,7 +69,7 @@ from ${object.company_id.name}. % set record = ctx.get('record') - % set company = record and record.company_id or user.company_id + % set company = record and record.company_id or ctx.get('company')
- ${user.company_id.name}
- ${user.company_id.phone or ''} + ${company.name}
+ ${company.phone or ''}
- % if user.company_id.email: - ${user.company_id.email}
+ % if company.email: + ${company.email}
% endif - % if user.company_id.website: - - ${user.company_id.website} + % if company.website: + + ${company.website} % endif