From be398b428a64b9aa58b2af972ee0e3fb7ce5d28e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 5 Jun 2023 09:33:39 +0000 Subject: [PATCH] [FIX] auth_*, sale: improve 'from' of templates by adding company fallback Emails on Sale Order, Invoice, Recovery cart. When no sales on sale.order use "COMPANY" as fallback before the current user. Reason is that odoobot is often used in automatized actions and having it as email_from is not really user friendly. Also add company fallback in auth modules email templates (if not already using it) for the same reason. Task-3346388 closes odoo/odoo#124472 X-original-commit: 597fc004148bf39e8f56e36e840aa6788872f237 Signed-off-by: Thibault Delavallee (tde) --- addons/account/data/mail_template_data.xml | 4 ++-- addons/auth_signup/data/mail_template_data.xml | 2 +- addons/auth_totp_mail/data/mail_template_data.xml | 1 + addons/sale/data/mail_template_data.xml | 6 +++--- addons/website_sale/data/mail_template_data.xml | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/account/data/mail_template_data.xml b/addons/account/data/mail_template_data.xml index 13f5c49d452..230b5e8e481 100644 --- a/addons/account/data/mail_template_data.xml +++ b/addons/account/data/mail_template_data.xml @@ -8,7 +8,7 @@ Invoice: Sending - {{ (object.invoice_user_id.email_formatted or user.email_formatted) }} + {{ (object.invoice_user_id.email_formatted or object.company_id.email_formatted or user.email_formatted) }} {{ object.partner_id.id }} {{ object.company_id.name }} Invoice (Ref {{ object.name or 'n/a' }}) Sent to customers with their invoices in attachment @@ -91,7 +91,7 @@ Credit Note: Sending - {{ (object.invoice_user_id.email_formatted or user.email_formatted) }} + {{ (object.invoice_user_id.email_formatted or object.company_id.email_formatted or user.email_formatted) }} {{ object.partner_id.id }} {{ object.company_id.name }} Credit Note (Ref {{ object.name or 'n/a' }}) Sent to customers with the credit note in attachment diff --git a/addons/auth_signup/data/mail_template_data.xml b/addons/auth_signup/data/mail_template_data.xml index 19b35598938..b25859d5531 100644 --- a/addons/auth_signup/data/mail_template_data.xml +++ b/addons/auth_signup/data/mail_template_data.xml @@ -198,7 +198,7 @@ Settings: Unregistered User Reminder Reminder for unregistered users - {{ object.company_id.partner_id.email_formatted }} + {{ (object.company_id.email_formatted or user.email_formatted) }} {{ object.email_formatted }} Sent automatically to admin if new user haven't responded to the invitation diff --git a/addons/auth_totp_mail/data/mail_template_data.xml b/addons/auth_totp_mail/data/mail_template_data.xml index 0694cc216ee..b30105ca555 100644 --- a/addons/auth_totp_mail/data/mail_template_data.xml +++ b/addons/auth_totp_mail/data/mail_template_data.xml @@ -4,6 +4,7 @@ Settings: 2Fa Invitation + {{ (object.company_id.email_formatted or user.email_formatted) }} Invitation to activate two-factor authentication on your Odoo account {{ object.partner_id.id }} {{ object.partner_id.lang }} diff --git a/addons/sale/data/mail_template_data.xml b/addons/sale/data/mail_template_data.xml index aa204883bc1..d5ae9526ed5 100644 --- a/addons/sale/data/mail_template_data.xml +++ b/addons/sale/data/mail_template_data.xml @@ -5,7 +5,7 @@ Sales: Send Quotation {{ object.company_id.name }} {{ object.state in ('draft', 'sent') and (ctx.get('proforma') and 'Proforma' or 'Quotation') or 'Order' }} (Ref {{ object.name or 'n/a' }}) - {{ (object.user_id.email_formatted or user.email_formatted) }} + {{ (object.user_id.email_formatted or object.company_id.email_formatted or user.email_formatted) }} {{ object.partner_id.id }} Used by salespeople when they send quotations or proforma to prospects @@ -48,7 +48,7 @@ Sales: Order Confirmation {{ object.company_id.name }} {{ (object.get_portal_last_transaction().state == 'pending') and 'Pending Order' or 'Order' }} (Ref {{ object.name or 'n/a' }}) - {{ (object.user_id.email_formatted or user.email_formatted) }} + {{ (object.user_id.email_formatted or object.company_id.email_formatted or user.email_formatted) }} {{ object.partner_id.id }} Sent to customers on order confirmation @@ -298,7 +298,7 @@ Sales: Order Cancellation {{ object.company_id.name }} {{ object.type_name }} Cancelled (Ref {{ object.name or 'n/a' }}) - {{ (object.user_id.email_formatted or user.email_formatted) }} + {{ (object.user_id.email_formatted or object.company_id.email_formatted or user.email_formatted) }} {{ object.partner_id.id }} Sent automatically to customers when you cancel an order diff --git a/addons/website_sale/data/mail_template_data.xml b/addons/website_sale/data/mail_template_data.xml index 58ac5ac7f15..4902c0a62e8 100644 --- a/addons/website_sale/data/mail_template_data.xml +++ b/addons/website_sale/data/mail_template_data.xml @@ -5,7 +5,7 @@ Ecommerce: Cart Recovery You left items in your cart! - {{ (object.user_id.email_formatted or user.email_formatted or '') }} + {{ (object.user_id.email_formatted or object.company_id.email_formatted or user.email_formatted or '') }} {{ object.partner_id.id }} If the setting is set, sent to authenticated visitors who abandoned their cart