[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).
This commit is contained in:
Pratima Gupta
2018-06-08 17:11:54 +02:00
committed by Thibault Delavallée
parent 417e15ff39
commit e1467490e0
3 changed files with 87 additions and 167 deletions
+85 -166
View File
@@ -1,173 +1,92 @@
<?xml version="1.0" ?>
<odoo>
<data>
<data noupdate="1">
<record id="sale_coupon.mail_template_sale_coupon" model="mail.template">
<field name="name">Coupon - Send by Email</field>
<field name="email_from">${object.program_id.company_id.email|safe}</field>
<field name="subject">Your reward coupon from ${object.program_id.company_id.name} </field>
<field name="partner_to">${object.partner_id.id}</field>
<field name="name">Coupon: Send by Email</field>
<field name="model_id" ref="sale_coupon.model_sale_coupon"/>
<field name="auto_delete" eval="True"/>
<field name="report_template" ref="report_coupon_code"/>
<field name="report_name">Your Coupon Code</field>
<field name="lang">${object.partner_id.lang}</field>
<field name="body_html" type="xml">
<div style="margin:auto;background-color:rgb(255, 255, 255);border: 1px solid rgb(240, 240, 240);max-width:600px;width:100%;">
<table align="center" style="text-align: center;" cellspacing="0" cellpadding="0" border="0" width="100%">
<tbody>
<tr>
<td width="70%" style="padding:20px 20px 20px 20px;vertical-align:middle;text-align: left;border-bottom: 3px solid rgb(255, 255, 255)">
<img src="/logo?company=${object.program_id.company_id.id}" alt="${object.program_id.company_id.name}" style="border:0px solid transparent; height: auto; max-width: 150px;" height="29"/>
</td>
</tr>
% if object.partner_id.name:
<tr>
<td style="padding: 5px 0px 0px 0px;">
<span>
<b> Congratulations </b> ${object.partner_id.name},
</span>
</td>
</tr>
% endif
<tr>
<td>
<div>Here is your reward from ${object.program_id.company_id.name}.</div>
<p class="oe_mt16"></p>
</td>
</tr>
% if object.program_id.reward_type == 'discount':
% if object.program_id.discount_type == 'fixed_amount':
<tr>
<td>
<div style="font-size: 50px; color: rgb(153, 51, 102);font-weight: bold;">
${'%s' % (format_amount(object.program_id.discount_fixed_amount, object.program_id.currency_id))}
</div>
</td>
</tr>
<tr>
<td>
<div style="font-size: 24px;">
OFF ON YOUR NEXT ORDER !
</div>
</td>
</tr>
%else
<tr>
<td>
<div style="font-size: 50px; color: rgb(153, 51, 102);font-weight: bold;">
${object.program_id.discount_percentage} %
</div>
</td>
</tr>
% if object.program_id.discount_apply_on == 'specific_product':
<tr>
<td>
<div style="font-size: 24px;">
${'ON %s' % (object.program_id.discount_specific_product_id.name.upper())}
</div>
</td>
</tr>
% elif object.program_id.discount_apply_on == 'cheapest_product':
<tr>
<td>
<div style="font-size: 24px;">
OFF ON THE CHEAPEST PRODUCT !
</div>
</td>
</tr>
% else
<tr>
<td>
<div style="font-size: 24px;">
OFF ON YOUR NEXT ORDER !
</div>
</td>
</tr>
% endif
% endif
% elif object.program_id.reward_type == 'product':
<tr>
<td>
<div style="font-size: 24px;">
${'GET %s FREE %s ON YOUR NEXT ORDER !' % (object.program_id.reward_product_quantity, object.program_id.reward_product_id.name.upper())}
</div>
</td>
</tr>
% elif object.program_id.reward_type == 'free_shipping':
<tr>
<td>
<div style="font-size: 24px;">
${'GET FREE SHIPPING ON YOUR NEXT ORDER !'}
</div>
</td>
</tr>
% endif
<tr>
<td>
<span>
<font style="font-size: 18px;">
Use this promo code
</font>
% if object.expiration_date:
<font style="font-size: 18px;">
before ${object.expiration_date}
</font>
% endif
</span>
</td>
</tr>
<tr>
<td>
<span>
<font style="font-size: 20px;">CODE:</font>
<strong style="padding: 5px;border-radius: 3px;background-color:#D9EAD3;font-size:18px;color:rgb(70, 70, 70);font-family:monospace;font-weight: bold;">
${object.code}
</strong>
</span>
</td>
</tr>
<tr>
<td>
% if object.program_id.rule_min_quantity not in [0, 1]
<span>
<font style="font-size: 14px;">
Minimum purchase of ${object.program_id.rule_min_quantity} products
</font>
</span>
% endif
</td>
</tr>
<tr>
<td>
% if object.program_id.rule_minimum_amount != 0.00
<span>
<font style="font-size: 14px;">
Valid for purchase above ${object.program_id.company_id.currency_id.symbol}${'%0.2f' % object.program_id.rule_minimum_amount |float}
</font>
</span>
% endif
</td>
</tr>
<tr>
<td style="padding: 20px 0px 20px 0px; border-top: 3px solid rgb(255, 255, 255);">
% if object.program_id.company_id.name:
<span style="font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;color: rgb(147, 147, 147);">
<strong>
${object.program_id.company_id.name}
</strong>
</span>
<div>
<p style="font-family:&quot;Lucida Grande&quot;, Helvetica, Verdana, Arial, sans-serif;text-align: center;color: rgb(147, 147, 147);font-weight: bold;font-size: 9px;">
Copyright © All Rights Reserved
</p>
</div>
% endif
</td>
</tr>
</tbody>
</table>
</div>
</field>
<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.partner_id.id}</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;">
% if object.partner_id.name:
Congratulations ${object.partner_id.name},<br />
% endif
Here is your reward from ${object.program_id.company_id.name}.<br />
% if object.program_id.reward_type == 'discount':
% if object.program_id.discount_type == 'fixed_amount':
<span style="font-size: 50px; color: #875A7B; font-weight: bold;">
${'%s' % format_amount(object.program_id.discount_fixed_amount, object.program_id.currency_id)}
</span><br />
<strong style="font-size: 24px;">off on your next order</strong><br />
%else
<span style="font-size: 50px; color: #875A7B; font-weight: bold;">
${object.program_id.discount_percentage} %
</span>
% if object.program_id.discount_apply_on == 'specific_product':
<br /><strong style="font-size: 24px;">
${'on %s' % object.program_id.discount_specific_product_id.name}
</strong>
% elif object.program_id.discount_apply_on == 'cheapest_product':
<br /><strong style="font-size: 24px;">
off on the cheapest product
</strong>
% else
<br /><strong style="font-size: 24px;">
off on your next order
</strong>
% endif
<br />
% endif
% elif object.program_id.reward_type == 'product':
<span style="font-size: 36px; color: #875A7B; font-weight: bold;">
${'get %s free %s' % (object.program_id.reward_product_quantity, object.program_id.reward_product_id.name)}
</span><br />
<strong style="font-size: 24px;">on your next order</strong><br />
% elif object.program_id.reward_type == 'free_shipping':
<span style="font-size: 36px; color: #875A7B; font-weight: bold;">
get free shipping
</span><br />
<strong style="font-size: 24px;">on your next order</strong><br />
% endif
</td></tr>
<tr style="margin-top: 16px"><td valign="top" style="text-align: center; font-size: 14px;">
Use this promo code
% if object.expiration_date:
before ${object.expiration_date}
% endif
<p style="margin-top: 16px;">
<strong style="padding: 16px 8px 16px 8px; border-radius: 3px; background-color: #F1F1F1;">
${object.code}
</strong>
</p>
% if object.program_id.rule_min_quantity not in [0, 1]
<span style="font-size: 14px;">
Minimum purchase of ${object.program_id.rule_min_quantity} products
</span><br />
% endif
% if object.program_id.rule_minimum_amount != 0.00
<span style="font-size: 14px;">
Valid for purchase above ${object.program_id.company_id.currency_id.symbol}${'%0.2f' % object.program_id.rule_minimum_amount |float}
</span><br />
% endif
<br/>
Thank you,
<br/>
% if object.order_id.user_id:
${object.order_id.user_id.signature | safe}
% endif
</td></tr>
</tbody></table>
</field>
<field name="report_template" ref="report_coupon_code"/>
<field name="report_name">Your Coupon Code</field>
<field name="auto_delete" eval="True"/>
<field name="user_signature" eval="False"/>
<field name="lang">${object.partner_id.lang}</field>
</record>
</data>
</odoo>
+1
View File
@@ -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'),
+1 -1
View File
@@ -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):