From e1467490e0d8228c1e61063aaa5eccb7ac75eb67 Mon Sep 17 00:00:00 2001 From: Pratima Gupta Date: Wed, 21 Mar 2018 11:18:24 +0530 Subject: [PATCH] [IMP] sale_coupon: make email templates bioutifoul Purpose of this commit is to enhance quality of templates proposed by Odoo and make them use notification layout when send by emails. Those emails are cleaner and more up to date compared to other emails. Including * revamping of coupon email to match current notification guidelines. It was using a very strange and different design. We choose to standardize it; * use the light notification template to encapsulate coupon emails when sending them by email; This commit is related to task ID 51122 (and PR #2060). --- data/sale_coupon_email_data.xml | 251 +++++++++++--------------------- models/sale_coupon.py | 1 + models/sale_order.py | 2 +- 3 files changed, 87 insertions(+), 167 deletions(-) diff --git a/data/sale_coupon_email_data.xml b/data/sale_coupon_email_data.xml index 4bae1fb0118..53857c9f4f4 100644 --- a/data/sale_coupon_email_data.xml +++ b/data/sale_coupon_email_data.xml @@ -1,173 +1,92 @@ - + - Coupon - Send by Email - ${object.program_id.company_id.email|safe} - Your reward coupon from ${object.program_id.company_id.name} - ${object.partner_id.id} + Coupon: Send by Email - - - Your Coupon Code - ${object.partner_id.lang} - -
- - - - - - % if object.partner_id.name: - - - - % endif - - - - % if object.program_id.reward_type == 'discount': - % if object.program_id.discount_type == 'fixed_amount': - - - - - - - %else - - - - % if object.program_id.discount_apply_on == 'specific_product': - - - - % elif object.program_id.discount_apply_on == 'cheapest_product': - - - - % else - - - - % endif - % endif - % elif object.program_id.reward_type == 'product': - - - - % elif object.program_id.reward_type == 'free_shipping': - - - - % endif - - - - - - - - - - - - - - - - -
- ${object.program_id.company_id.name} -
- - Congratulations ${object.partner_id.name}, - -
-
Here is your reward from ${object.program_id.company_id.name}.
-

-
-
- ${'%s' % (format_amount(object.program_id.discount_fixed_amount, object.program_id.currency_id))} -
-
-
- OFF ON YOUR NEXT ORDER ! -
-
-
- ${object.program_id.discount_percentage} % -
-
-
- ${'ON %s' % (object.program_id.discount_specific_product_id.name.upper())} -
-
-
- OFF ON THE CHEAPEST PRODUCT ! -
-
-
- OFF ON YOUR NEXT ORDER ! -
-
-
- ${'GET %s FREE %s ON YOUR NEXT ORDER !' % (object.program_id.reward_product_quantity, object.program_id.reward_product_id.name.upper())} -
-
-
- ${'GET FREE SHIPPING ON YOUR NEXT ORDER !'} -
-
- - - Use this promo code - - % if object.expiration_date: - - before ${object.expiration_date} - - % endif - -
- - CODE: - - ${object.code} - - -
- % if object.program_id.rule_min_quantity not in [0, 1] - - - Minimum purchase of ${object.program_id.rule_min_quantity} products - - - % endif -
- % if object.program_id.rule_minimum_amount != 0.00 - - - Valid for purchase above ${object.program_id.company_id.currency_id.symbol}${'%0.2f' % object.program_id.rule_minimum_amount |float} - - - % endif -
- % if object.program_id.company_id.name: - - - ${object.program_id.company_id.name} - - -
-

- Copyright © All Rights Reserved -

-
- % endif -
-
-
+ Your reward coupon from ${object.program_id.company_id.name} + ${object.program_id.company_id.email|safe} + ${object.partner_id.id} + + + + +
+ % if object.partner_id.name: + Congratulations ${object.partner_id.name},
+ % endif + + Here is your reward from ${object.program_id.company_id.name}.
+ + % if object.program_id.reward_type == 'discount': + % if object.program_id.discount_type == 'fixed_amount': + + ${'%s' % format_amount(object.program_id.discount_fixed_amount, object.program_id.currency_id)} +
+ off on your next order
+ %else + + ${object.program_id.discount_percentage} % + + % if object.program_id.discount_apply_on == 'specific_product': +
+ ${'on %s' % object.program_id.discount_specific_product_id.name} + + % elif object.program_id.discount_apply_on == 'cheapest_product': +
+ off on the cheapest product + + % else +
+ off on your next order + + % endif +
+ % endif + % elif object.program_id.reward_type == 'product': + + ${'get %s free %s' % (object.program_id.reward_product_quantity, object.program_id.reward_product_id.name)} +
+ on your next order
+ % elif object.program_id.reward_type == 'free_shipping': + + get free shipping +
+ on your next order
+ % endif +
+ Use this promo code + % if object.expiration_date: + before ${object.expiration_date} + % endif +

+ + ${object.code} + +

+ % if object.program_id.rule_min_quantity not in [0, 1] + + Minimum purchase of ${object.program_id.rule_min_quantity} products +
+ % endif + % if object.program_id.rule_minimum_amount != 0.00 + + Valid for purchase above ${object.program_id.company_id.currency_id.symbol}${'%0.2f' % object.program_id.rule_minimum_amount |float} +
+ % endif +
+ Thank you, +
+ % if object.order_id.user_id: + ${object.order_id.user_id.signature | safe} + % endif +
+
+ + Your Coupon Code + + + ${object.partner_id.lang}
\ No newline at end of file diff --git a/models/sale_coupon.py b/models/sale_coupon.py index 8af3a9485ce..38534cf85dc 100644 --- a/models/sale_coupon.py +++ b/models/sale_coupon.py @@ -93,6 +93,7 @@ class SaleCoupon(models.Model): default_use_template=bool(template), default_template_id=template.id, default_composition_mode='comment', + custom_layout='mail.mail_notification_light', ) return { 'name': _('Compose Email'), diff --git a/models/sale_order.py b/models/sale_order.py index d88d8cfc3d9..05f57080422 100644 --- a/models/sale_order.py +++ b/models/sale_order.py @@ -167,7 +167,7 @@ class SaleOrder(models.Model): self.generated_coupon_ids |= coupon template = self.env.ref('sale_coupon.mail_template_sale_coupon', raise_if_not_found=False) if template: - self.message_post_with_template(template.id, composition_mode='comment') + coupon.message_post_with_template(template.id, composition_mode='comment', notif_layout='mail.mail_notification_light') return coupon def _get_applicable_programs(self):