diff options
| author | nie <nie@odoo.com> | 2021-03-18 15:14:59 +0000 |
|---|---|---|
| committer | nie <nie@odoo.com> | 2021-03-25 07:51:38 +0000 |
| commit | 981eab82dbb15783bef7e010ffbc21735710dd0a (patch) | |
| tree | 4ddd405a41a26e6f4144d76f8e91199d2f48a102 /addons | |
| parent | 3826a2645b94e0f62c719814c4dbe4cc6502e1f2 (diff) | |
[FIX] sale_coupon: translate email subject and template
Steps:
- Install Sales
- Go to Settings / Translations / Languages
- Install Dutch
- Go to Settings / Users & Companies / Users
- Change demo's language to Dutch
- Go to Sales / Configuration / Settings
- Activate Coupons & Promotions
- Go to Sales / Products / Coupon Programs
- Create a new Coupon Program
- Click Generate Coupon
- Generation Type: Number of Selected Customers
- Matching rule: Name contains demo
- Generate
- Go to Settings / Technical / Email / Emails
- Open the email you just sent
Bug:
Parts of the email are not translated
Explanation:
The `lang` field is used to determine the template's language. Coupon
emails where missing one.
Also, the subject of the email wasn't translated.
opw:2467640
closes odoo/odoo#68316
X-original-commit: 6fbca2745a36ade4d8e8bdd2f015fd831b872d67
Signed-off-by: backspac <backspac@users.noreply.github.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/coupon/data/coupon_email_data.xml | 1 | ||||
| -rw-r--r-- | addons/coupon/i18n/coupon.pot | 6 | ||||
| -rw-r--r-- | addons/coupon/wizard/coupon_generate.py | 6 |
3 files changed, 11 insertions, 2 deletions
diff --git a/addons/coupon/data/coupon_email_data.xml b/addons/coupon/data/coupon_email_data.xml index d28e2f80947..71d2f80eb8f 100644 --- a/addons/coupon/data/coupon_email_data.xml +++ b/addons/coupon/data/coupon_email_data.xml @@ -7,6 +7,7 @@ <field name="subject">Your reward coupon from ${object.program_id.company_id.name} </field> <field name="email_from">${object.program_id.company_id.email | safe}</field> <field name="partner_to">${object.order_id.partner_id.id or object.partner_id.id}</field> + <field name="lang">${object.partner_id.lang}</field> <field name="body_html" type="html"> <table border="0" cellpadding="0" cellspacing="0" style="width:100%; margin:0px auto;"><tbody> <tr><td valign="top" style="text-align: center; font-size: 14px;"> diff --git a/addons/coupon/i18n/coupon.pot b/addons/coupon/i18n/coupon.pot index 4eb6d3007a7..05e2694d9fd 100644 --- a/addons/coupon/i18n/coupon.pot +++ b/addons/coupon/i18n/coupon.pot @@ -46,6 +46,12 @@ msgid "%s%% discount on total amount" msgstr "" #. module: coupon +#: code:addons/coupon/wizard/coupon_generate.py:0 +#, python-format +msgid "%s, a coupon has been generated for you" +msgstr "" + +#. module: coupon #: model_terms:ir.ui.view,arch_db:coupon.report_coupon msgid "*Valid for following products:" msgstr "" diff --git a/addons/coupon/wizard/coupon_generate.py b/addons/coupon/wizard/coupon_generate.py index f89ee5558c4..46318b04d38 100644 --- a/addons/coupon/wizard/coupon_generate.py +++ b/addons/coupon/wizard/coupon_generate.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from odoo import api, fields, models +from odoo import _, api, fields, models import ast from odoo.osv import expression @@ -33,7 +33,9 @@ class CouponGenerate(models.TransientModel): for partner in self.env['res.partner'].search(ast.literal_eval(self.partners_domain)): vals.update({'partner_id': partner.id, 'state': 'sent' if partner.email else 'new'}) coupon = self.env['coupon.coupon'].create(vals) - subject = '%s, a coupon has been generated for you' % (partner.name) + context = dict(lang=partner.lang) + subject = _('%s, a coupon has been generated for you') % (partner.name) + del context template = self.env.ref('coupon.mail_template_sale_coupon', raise_if_not_found=False) if template: email_values = {'email_to': partner.email, 'email_from': self.env.user.email or '', 'subject': subject} |
