[FIX] mail, sale, account: company used in notification emails

The `user` variable in the mail templates is the `self.env.user`,
https://github.com/odoo/odoo/blob/10.0/addons/mail/models/mail_template.py#L370

which will always be the administrator in the use case
of a notification email
https://github.com/odoo/odoo/blob/10.0/addons/mail/models/res_partner.py#L151-L156

Using `user.company_id` to determine the company of the sales order
or the invoice is therefore wrong, as it will always be the administrator
company, which can be different than the order/invoice company.

opw-706267
This commit is contained in:
Denis Ledoux
2017-02-13 15:18:23 +01:00
committed by Nicolas Martinelli
parent 42e6e8c312
commit 41ffb5032b
3 changed files with 25 additions and 16 deletions
+10 -8
View File
@@ -62,6 +62,8 @@ from ${object.company_id.name}.
<field name="auto_delete" eval="True"/>
<field name="body_html"><![CDATA[<html>
<head></head>
% set record = ctx.get('record')
% set company = record and record.company_id or user.company_id
<body style="margin: 0; padding: 0;">
<table border="0" width="100%" cellpadding="0" bgcolor="#ededed" style="padding: 20px; background-color: #ededed" summary="o_mail_notification">
<tbody>
@@ -77,7 +79,7 @@ from ${object.company_id.name}.
</span>
</td>
<td valign="middle" align="right">
<img src="/logo.png" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${user.company_id.name}">
<img src="/logo.png" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${company.name}">
</td>
</tr>
</table>
@@ -103,16 +105,16 @@ from ${object.company_id.name}.
<table width="590" border="0" cellpadding="0" bgcolor="#875A7B" style="min-width: 590px; background-color: rgb(135,90,123); padding: 20px;">
<tr>
<td valign="middle" align="left" style="color: #fff; padding-top: 10px; padding-bottom: 10px; font-size: 12px;">
${user.company_id.name}<br/>
${user.company_id.phone or ''}
${company.name}<br/>
${company.phone or ''}
</td>
<td valign="middle" align="right" style="color: #fff; padding-top: 10px; padding-bottom: 10px; font-size: 12px;">
% if user.company_id.email:
<a href="mailto:${user.company_id.email}" style="text-decoration:none; color: white;">${user.company_id.email}</a><br/>
% if company.email:
<a href="mailto:${company.email}" style="text-decoration:none; color: white;">${company.email}</a><br/>
% endif
% if user.company_id.website:
<a href="${user.company_id.website}" style="text-decoration:none; color: white;">
${user.company_id.website}
% if company.website:
<a href="${company.website}" style="text-decoration:none; color: white;">
${company.website}
</a>
% endif
</td>
+5
View File
@@ -77,11 +77,16 @@ class Partner(models.Model):
is_discussion = message.subtype_id.id == self.env['ir.model.data'].xmlid_to_res_id('mail.mt_comment')
record = False
if message.res_id and message.model in self.env:
record = self.env[message.model].browse(message.res_id)
return {
'signature': signature,
'website_url': website_url,
'company_name': company_name,
'model_name': model_name,
'record': record,
'record_name': record_name,
'tracking': tracking,
'is_discussion': is_discussion,
+10 -8
View File
@@ -63,6 +63,8 @@ from ${object.company_id.name}.
<field name="auto_delete" eval="True"/>
<field name="body_html"><![CDATA[<html>
<head></head>
% set record = ctx.get('record')
% set company = record and record.company_id or user.company_id
<body style="margin: 0; padding: 0;">
<table border="0" width="100%" cellpadding="0" bgcolor="#ededed" style="padding: 20px; background-color: #ededed" summary="o_mail_notification">
<tbody>
@@ -78,7 +80,7 @@ from ${object.company_id.name}.
</span>
</td>
<td valign="middle" align="right">
<img src="/logo.png" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${user.company_id.name}">
<img src="/logo.png" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${company.name}">
</td>
</tr>
</table>
@@ -104,16 +106,16 @@ from ${object.company_id.name}.
<table width="590" border="0" cellpadding="0" bgcolor="#875A7B" style="min-width: 590px; background-color: rgb(135,90,123); padding: 20px;">
<tr>
<td valign="middle" align="left" style="color: #fff; padding-top: 10px; padding-bottom: 10px; font-size: 12px;">
${user.company_id.name}<br/>
${user.company_id.phone or ''}
${company.name}<br/>
${company.phone or ''}
</td>
<td valign="middle" align="right" style="color: #fff; padding-top: 10px; padding-bottom: 10px; font-size: 12px;">
% if user.company_id.email:
<a href="mailto:${user.company_id.email}" style="text-decoration:none; color: white;">${user.company_id.email}</a><br/>
% if company.email:
<a href="mailto:${company.email}" style="text-decoration:none; color: white;">${company.email}</a><br/>
% endif
% if user.company_id.website:
<a href="${user.company_id.website}" style="text-decoration:none; color: white;">
${user.company_id.website}
% if company.website:
<a href="${company.website}" style="text-decoration:none; color: white;">
${company.website}
</a>
% endif
</td>