From a21864c36cfc9a10108fc499a6b950bcd6dc5b3a Mon Sep 17 00:00:00 2001
From: Nans Lefebvre
Date: Mon, 4 Feb 2019 09:09:08 +0000
Subject: [PATCH] [FIX] purchase: fix mail templates
Activate multi-company, deactivate the common contact book.
Create a PO P with user U1 in company A. Switch to company B.
User U2 in company A tries to send P by email.
Rendering of the template fails, because it tries to access object.create_uid,
which breaks multi-company record rules.
The signature was not working because it used user_id, a non-existing field,
instead of create_uid.
opw 1930521
closes odoo/odoo#30868
---
addons/purchase/data/mail_template_data.xml | 15 ++++++++++-----
addons/purchase/i18n/purchase.pot | 11 ++++++++---
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/addons/purchase/data/mail_template_data.xml b/addons/purchase/data/mail_template_data.xml
index ceb19ec9763..65b63e324f7 100644
--- a/addons/purchase/data/mail_template_data.xml
+++ b/addons/purchase/data/mail_template_data.xml
@@ -5,7 +5,7 @@
RFQ - Send by Email
- ${(object.create_uid.email and '"%s" <%s>' % (object.create_uid.name, object.create_uid.email) or '')|safe}
+ ${(object.sudo().create_uid.email and '"%s" <%s>' % (object.sudo().create_uid.name, object.sudo().create_uid.email) or '')|safe}
${object.company_id.name} Order (Ref ${object.name or 'n/a' })
${object.partner_id.id}
@@ -32,11 +32,11 @@ amounting in ${format_amount(object.amount_total, object.currency_id)}
from ${object.company_id.name}.
-Do not hesitate to contact us, further you have any question.
+Do not hesitate to contact us if you have any further question.
Best regards,
-% if object.user_id and object.user_id.signature:
- ${object.user_id.signature | safe}
+% if object.sudo().create_uid and object.sudo().create_uid.signature:
+ ${object.sudo().create_uid.signature | safe}
% endif
]]>
@@ -46,7 +46,7 @@ from ${object.company_id.name}.
Purchase Order - Send by Email
- ${(object.create_uid.email and '"%s" <%s>' % (object.create_uid.name, object.create_uid.email) or '')|safe}
+ ${(object.sudo().create_uid.email and '"%s" <%s>' % (object.sudo().create_uid.name, object.sudo().create_uid.email) or '')|safe}
${object.company_id.name} Order (Ref ${object.name or 'n/a' })
${object.partner_id.id}
@@ -74,6 +74,11 @@ from ${object.company_id.name}.
You can reply to this email if you have any questions.
Thank you,
+
+% if object.sudo().create_uid and object.sudo().create_uid.signature:
+ ${object.sudo().create_uid.signature | safe}
+% endif
+
]]>
diff --git a/addons/purchase/i18n/purchase.pot b/addons/purchase/i18n/purchase.pot
index ceea31343a4..c11326da530 100644
--- a/addons/purchase/i18n/purchase.pot
+++ b/addons/purchase/i18n/purchase.pot
@@ -36,11 +36,11 @@ msgid "\n"
"from ${object.company_id.name}.\n"
"\n"
"\n"
-"Do not hesitate to contact us, further you have any question.
\n"
+"Do not hesitate to contact us if you have any further question.
\n"
"Best regards,
\n"
"\n"
-"% if object.user_id and object.user_id.signature:\n"
-" ${object.user_id.signature | safe}\n"
+"% if object.sudo().create_uid and object.sudo().create_uid.signature:\n"
+" ${object.sudo().create_uid.signature | safe}\n"
"% endif\n"
"
\n"
""
@@ -68,6 +68,11 @@ msgid "\n"
"\n"
"You can reply to this email if you have any questions.
\n"
"Thank you,
\n"
+"\n"
+"% if object.sudo().create_uid and object.sudo().create_uid.signature:\n"
+" ${object.sudo().create_uid.signature | safe}\n"
+"% endif\n"
+"
\n"
""
msgstr ""