Permalink
Browse files

code improvement

  • Loading branch information...
mpa-odoo committed Jan 21, 2019
1 parent 151b07b commit 3eaba42661d8d3cfa7051e12d69ff83867f948d1
Showing with 55 additions and 32 deletions.
  1. +34 −22 addons/sale/data/mail_data.xml
  2. +7 −2 addons/sale/models/sale.py
  3. +14 −8 addons/sale/views/res_config_settings_views.xml
@@ -81,25 +81,29 @@
<div style="margin: 0px; padding: 0px;">
<p style="margin: 0px; padding: 0px; font-size: 13px;">
% set doc_name = 'quotation' if object.state in ('draft', 'sent') else 'order'
Dear ${object.partner_id.name}
Hello ${object.partner_id.name}
% if object.partner_id.parent_id:
(${object.partner_id.parent_id.name})
% endif
,
<br /><br />
Here is
% if ctx.get('proforma')
in attachment your pro-forma invoice
% else
the ${doc_name} <strong>${object.name}</strong>
% endif
% if object.origin:
(with reference: ${object.origin} )
<br/><br/>
Your
% if ctx.get('proforma'):
Pro forma invoice for ${doc_name} <strong>${object.name}</strong>
% if object.origin:
(with reference: ${object.origin} )
% endif
amounting in <strong>${format_amount(object.amount_total, object.pricelist_id.currency_id)}</strong> in available.
% else:
${doc_name} <strong>${object.name}</strong>
% if object.origin:
(with reference: ${object.origin} )
% endif
amounting in <strong>${format_amount(object.amount_total, object.pricelist_id.currency_id)}</strong> is ready for review.
% endif
amounting in <strong>${format_amount(object.amount_total, object.pricelist_id.currency_id)}</strong>
from ${object.company_id.name}.
<br /><br />
<br/><br/>
Do not hesitate to contact us if you have any question.
<br/>
</p>
</div>
</field>
@@ -111,7 +115,7 @@
</record>

<record id="confirmation_mail_template_sale" model="mail.template">
<field name="name">Confirmation Email</field>
<field name="name">Sale Order: Confirmation Email</field>
<field name="model_id" ref="sale.model_sale_order"/>
<field name="email_from">${object.user_id.email_formatted |safe}</field>
<field name="partner_to">${object.partner_id.id}</field>
@@ -120,20 +124,23 @@
<div style="margin: 0px; padding: 0px;">
<p style="margin: 0px; padding: 0px; font-size: 12px;">
% if object.partner_id.parent_id:
Dear ${object.partner_id.name} (${object.partner_id.parent_id.name}),
Hello ${object.partner_id.name} (${object.partner_id.parent_id.name}),
% else:
Dear ${object.partner_id.name},
Hello ${object.partner_id.name},
% endif
<br /><br />
<br/><br/>
% set transaction = object.get_portal_last_transaction()
Thank you for your order <strong>${object.name}</strong> amounting in <strong>${format_amount(object.amount_total, object.currency_id)}</strong>.
% if transaction and transaction.state == 'pending':
It will be validated when the payment is received.
Your order <strong>${object.name}</strong> amounting in <strong>${format_amount(object.amount_total, object.currency_id)}</strong>.
% if object.state == 'sale' or (transaction and transaction.state in ('done', 'authorized')) :
has been confirmed.<br/>
Thank you for your trust!
% elif transaction and transaction.state == 'pending' :
is pending.It will be confirmed when the payment is received.
% endif
<br/><br/>
Do not hesitate to contact us if you have any question.
<br/><br/><br/>
<center><a href="${object.get_portal_url()}" target="_blank" style="background-color: #875A7B; padding: 8px 16px 8px 16px; text-decoration: none; color: #fff; border-radius: 5px; font-size:13px;">View Your Order</a></center>
<center><a href="${object.get_portal_url()}" target="_blank" style="background-color: #875A7B; padding: 8px 16px 8px 16px; text-decoration: none; color: #fff; border-radius: 5px; font-size:13px;">View ${(object.state == 'sale' or object.website_id) and 'Order' or 'Quotation'}</a></center>
<br/><br/>
% if object.website_id:
<table width="100%" style="color: #454748; font-size: 12px; border-collapse: collapse;">
@@ -213,7 +220,12 @@
<tr>
<td>
<strong>Shipping Method:</strong>
${object.carrier_id.name} (${format_amount(object.delivery_price, object.currency_id)})
${object.carrier_id.name}
% if object.delivery_price == 0.0:
(Free)
% else:
(${format_amount(object.delivery_price, object.currency_id)})
% endif
</td>
</tr>
% endif
@@ -591,8 +591,13 @@ def action_quotation_send(self):
'''
self.ensure_one()
ir_model_data = self.env['ir.model.data']
custom_layout = "mail.mail_notification_paynow"
try:
template_id = ir_model_data.get_object_reference('sale', 'email_template_edi_sale')[1]
if self.state == 'sale':
template_id = int(self.env['ir.config_parameter'].sudo().get_param('sale.default_confirmation_template'))
custom_layout = "mail.mail_notification_light"
else:
template_id = ir_model_data.get_object_reference('sale', 'email_template_edi_sale')[1]
except ValueError:
template_id = False
try:
@@ -606,7 +611,7 @@ def action_quotation_send(self):
'default_template_id': template_id,
'default_composition_mode': 'comment',
'mark_so_as_sent': True,
'custom_layout': "mail.mail_notification_paynow",
'custom_layout': custom_layout,
'proforma': self.env.context.get('proforma', False),
'force_email': True
}
@@ -161,14 +161,20 @@
<div class="text-muted">
Request an online payment to confirm orders
</div>
<div class="content-group" attrs="{'invisible': [('portal_confirmation_pay', '=', False)]}">
<div class="mt16">
<label for="confirmation_template_id" string="Confirmation Email" class="o_light_label"/>
<field name="confirmation_template_id" class="oe_inline"/>
</div>
<div>
<button name='%(payment.action_payment_acquirer)d' icon="fa-arrow-right" type="action" string="Payment Acquirers" class="btn-link"/>
</div>
<div attrs="{'invisible': [('portal_confirmation_pay', '=', False)]}">
<button name='%(payment.action_payment_acquirer)d' icon="fa-arrow-right" type="action" string="Payment Acquirers" class="btn-link"/>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box" id="confirmation_email_setting" attrs="{'invisible': [('portal_confirmation_pay', '=', False) , ('portal_confirmation_sign', '=', False)]}">
<div class="o_setting_right_pane">
<span class="o_form_label">Confirmation Email</span>
<div class="text-muted">
Automatic email sent after the customer has signed or paid online.
</div>
<div class="row mt16">
<label for="confirmation_template_id" string="Email Template" class="col-lg-4 o_light_label"/>
<field name="confirmation_template_id" class="oe_inline"/>
</div>
</div>
</div>

0 comments on commit 3eaba42

Please sign in to comment.