[FIX] mail, *: add signature in email layouts only if requested and set

* = account, purchase, sale

Purpose of this commit is to add signature only if really asked. A variable
is available for that purpose (``email_add_signature``, recently renamed from
``add_sign``). We also correctly check signature is not void or pseudo-void
using tool ``is_html_empty``. Indeed editor may generates pseudo-void content
like ``<p><br /></p>``.

As signature is not added when a template is used (see composer code) we ensure
it is defined in mail templates used in "Send by email" flows. Indeed we cannot
know if a template already has a signature or not. To avoid having twice a
signature no signature is added in email notification layout when a template
is involved.

Continuation of odoo/odoo#76418 .

Task-2712450 (Mail/Sale: Improve 'Pay Now' notification template)

Part-of: odoo/odoo#82167
This commit is contained in:
Thibault Delavallée
2022-01-31 17:47:33 +00:00
parent b78344f99c
commit bf6c805b66
4 changed files with 29 additions and 7 deletions
+3 -3
View File
@@ -46,7 +46,7 @@
</t>
<br /><br />
Do not hesitate to contact us if you have any questions.
<t t-if="object.invoice_user_id.signature">
<t t-if="not is_html_empty(object.invoice_user_id.signature)">
<br />
<t t-out="object.invoice_user_id.signature or ''">--<br/>Mitchell Admin</t>
</t>
@@ -75,7 +75,7 @@
Do not hesitate to contact us if you have any questions.
<br/><br/>
Best regards,
<t t-if="user.signature">
<t t-if="not is_html_empty(user.signature)">
<br/>
<t t-out="user.signature or ''">--<br/>Mitchell Admin</t>
</t>
@@ -119,7 +119,7 @@
from <t t-out="object.company_id.name or ''">YourCompany</t>.
<br /><br />
Do not hesitate to contact us if you have any questions.
<t t-if="object.invoice_user_id.signature">
<t t-if="not is_html_empty(object.invoice_user_id.signature)">
<br />
<t t-out="object.invoice_user_id.signature or ''">--<br/>Mitchell Admin</t>
</t>
@@ -49,7 +49,7 @@
<li><t t-esc="tracking[0]"/>: <t t-esc="tracking[1]"/> -&gt; <t t-esc="tracking[2]"/></li>
</t>
</ul>
<div t-if="signature" t-out="signature" style="font-size: 13px;"/>
<div t-if="email_add_signature and not is_html_empty(signature)" t-out="signature" style="font-size: 13px;"/>
<p style="color: #555555; margin-top:32px;">
Sent
<span t-if="company.name">
@@ -177,12 +177,12 @@
<t t-esc="access_name"/>
</a>
</div>
<t t-if="'user_id' in record and record.user_id and not record.env.user._is_superuser() and signature != ''">
<t t-if="email_add_signature and 'user_id' in record and record.user_id and not record.env.user._is_superuser() and not is_html_empty(record.user_id.sudo().signature)">
<div style="margin: 0px; padding: 0px; font-size:13px;">
Best regards,
</div>
<div>&amp;nbsp;</div>
<div t-if="record.user_id.sudo().signature" style="font-size: 13px;">
<div style="font-size: 13px;">
<div t-out="record.user_id.sudo().signature"/>
</div>
</t>
@@ -23,6 +23,10 @@
If you have any questions, please do not hesitate to contact us.
<br/><br/>
Best regards,
<t t-if="not is_html_empty(object.user_id.signature)">
<br />
<t t-out="object.user_id.signature or ''">--<br/>Mitchell Admin</t>
</t>
</p>
</div></field>
<field name="report_template" ref="report_purchase_quotation"/>
@@ -56,6 +60,11 @@
<br/><br/>
Could you please acknowledge the receipt of this order?
</t>
<t t-if="not is_html_empty(object.user_id.signature)">
<br />
<t t-out="object.user_id.signature or ''">--<br/>Mitchell Admin</t>
</t>
<br/><br/>
</p>
</div></field>
<field name="report_template" ref="action_report_purchase_order"/>
@@ -90,6 +99,11 @@
<strong>undefined</strong>.
</t>
Could you please confirm it will be delivered on time?
<t t-if="not is_html_empty(object.user_id.signature)">
<br />
<t t-out="object.user_id.signature or ''">--<br/>Mitchell Admin</t>
</t>
<br/><br/>
</p>
</div></field>
<field name="report_template" ref="action_report_purchase_order"/>
+9 -1
View File
@@ -30,7 +30,11 @@
</t>
<br/><br/>
Do not hesitate to contact us if you have any questions.
<br/>
<t t-if="not is_html_empty(object.user_id.signature)">
<br />
<t t-out="object.user_id.signature or ''">--<br/>Mitchell Admin</t>
</t>
<br/><br/>
</p>
</div>
</field>
@@ -65,6 +69,10 @@
</t>
<br/><br/>
Do not hesitate to contact us if you have any questions.
<t t-if="not is_html_empty(object.user_id.signature)">
<br />
<t t-out="object.user_id.signature or ''">--<br/>Mitchell Admin</t>
</t>
<br/><br/>
</p>
<t t-if="hasattr(object, 'website_id') and object.website_id">