[FIX] website_sale: Allow to enter a coupon code on 'Payment' page
A user may want to enter a coupon on the 'Payment' page, for example after he selected his delivery method. That way, he isn't forced to come back on the 'Preview Order' page to enter the coupon and reselect its shipping and delivery addresses.
This commit is contained in:
@@ -58,7 +58,6 @@ class AccountConfigSettings(models.TransientModel):
|
||||
|
||||
@api.depends('company_id')
|
||||
def _compute_has_chart_of_accounts(self):
|
||||
# import pdb; pdb.set_trace()
|
||||
self.has_chart_of_accounts = bool(self.company_id.chart_template_id)
|
||||
|
||||
def set_group_multi_currency(self):
|
||||
@@ -68,7 +67,6 @@ class AccountConfigSettings(models.TransientModel):
|
||||
|
||||
def set_default_product_taxes(self):
|
||||
""" Set the product taxes if they have changed """
|
||||
# import pdb; pdb.set_trace()
|
||||
ir_values_obj = self.env['ir.values']
|
||||
if self.default_sale_tax_id:
|
||||
ir_values_obj.sudo().set_default('product.template', "taxes_id", [self.default_sale_tax_id.id], for_all_users=True, company_id=self.company_id.id)
|
||||
|
||||
@@ -1029,16 +1029,16 @@
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="reduction_code" inherit_id="website_sale.cart" active="False" customize_show="True" name="Coupon Code">
|
||||
<template id="reduction_code" inherit_id="website_sale.cart" active="True" customize_show="True" name="Coupon Code">
|
||||
<xpath expr="//div[@id='right_column']" position="inside">
|
||||
<h4>Coupon Code</h4>
|
||||
<p>
|
||||
Have a coupon code? Fill in this field and apply.
|
||||
</p>
|
||||
<t t-if="code_not_available">
|
||||
<t t-if="code_not_available" name="code_not_available">
|
||||
<p class="bg-warning">This promo code is not available</p>
|
||||
</t>
|
||||
<form t-if="website_sale_order and website_sale_order.website_order_line" action="/shop/pricelist" method="post" class="mb32">
|
||||
<form t-if="website_sale_order and website_sale_order.website_order_line" action="/shop/pricelist" method="post" class="mb32" name="coupon_code">
|
||||
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()" />
|
||||
<div class="input-group">
|
||||
<input name="promo" class="form-control" type="text" placeholder="code..." t-att-value="website_sale_order.pricelist_id.code or None" />
|
||||
@@ -1304,7 +1304,7 @@
|
||||
</div>
|
||||
</t>
|
||||
</div>
|
||||
<div class="col-md-8 col-md-offset-2 oe_cart">
|
||||
<div class="col-md-12 oe_cart">
|
||||
<div class='row'>
|
||||
<t t-call="website_sale.wizard_checkout">
|
||||
<t t-set="step" t-value="40" />
|
||||
@@ -1312,7 +1312,7 @@
|
||||
<h2 class="mb32 ml16">Confirm Order</h2>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class='col-md-12'>
|
||||
<div class='col-md-8 col-sm-9'>
|
||||
<table class="table table-striped table-condensed" id="cart_products" t-if="website_sale_order and website_sale_order.website_order_line">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -1349,84 +1349,85 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<t t-call="website_sale.total">
|
||||
<t t-set='extra_class' t-value='"col-sm-4 col-sm-offset-8 col-xs-8 col-xs-offset-4"'/>
|
||||
</t>
|
||||
</div>
|
||||
<div class="clearfix" />
|
||||
<div class="oe_structure" />
|
||||
</div>
|
||||
<div class="js_payment mb64 row" t-if="acquirers and website_sale_order.amount_total" id="payment_method">
|
||||
<div class="col-lg-5 col-sm-6">
|
||||
<h4>Payment Method:</h4>
|
||||
<ul class="list-unstyled">
|
||||
<t t-set="payment_methods_available" t-value="False"/>
|
||||
<t t-set="partner_country" t-value="website_sale_order and website_sale_order.partner_invoice_id.country_id"/>
|
||||
<t t-foreach="acquirers or []" t-as="acquirer">
|
||||
<li t-if="not acquirer.country_ids or partner_country in acquirer.country_ids">
|
||||
<label t-if="acquirer.button">
|
||||
<input t-att-value="acquirer.id" type="radio" name="acquirer" t-att-checked="acquirers[0] == acquirer" />
|
||||
<span t-field="acquirer.image_small" t-att-title="acquirer.name" t-options='{"widget": "image", "style":"max-width: 60px; display: inline-block"}'/>
|
||||
<span t-field="acquirer.name" />
|
||||
<span t-if="acquirer.fees_active">(processing fees apply)</span>
|
||||
</label>
|
||||
<t t-set="payment_methods_available" t-value="True"/>
|
||||
</li>
|
||||
</t>
|
||||
<li t-if="not payment_methods_available">
|
||||
<div class="alert alert-warning">
|
||||
<span>No payment gateway is available for your country</span>
|
||||
</div>
|
||||
</li>
|
||||
<li t-if="any(token for token in tokens if not token.acquirer_id.country_ids or partner_country in token.acquirer_id.country_ids)">
|
||||
<label>
|
||||
<input type="radio" name="acquirer" />
|
||||
<span class='fa fa-2x fa-credit-card'/>
|
||||
Saved Cards
|
||||
</label>
|
||||
|
||||
<div class="list-group">
|
||||
<t t-foreach='tokens' t-as='token'>
|
||||
<a t-if="not token.acquirer_id.country_ids or partner_country in token.acquirer_id.country_ids" class="list-group-item btn_payment_token" t-att-data-acquirer="token.acquirer_id.id" t-att-data-token='token.id'>
|
||||
<span class="js_radio fa fa-circle-o"></span>&nbsp;
|
||||
<t t-esc="token.name" />
|
||||
<t t-if="len(set(tokens.mapped('acquirer_id')))>1">
|
||||
(<t t-esc='token.acquirer_id.name'/>)
|
||||
</t>
|
||||
<span t-if="token.acquirer_id.fees_active">(processing fees apply)</span>
|
||||
</a>
|
||||
</t>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-lg-5 col-lg-offset-2 col-sm-6 text-right">
|
||||
<t t-foreach="acquirers or []" t-as="acquirer" id="acquirers_list">
|
||||
<div t-att-data-id="acquirer.id" class="oe_sale_acquirer_button hidden pull-right">
|
||||
<div t-raw="acquirer.button" />
|
||||
<div class="token_hide">
|
||||
<div t-if="acquirer.save_token == 'ask'">
|
||||
<input type="checkbox" name="odoo_save_token" id="odoo_save_token"/>
|
||||
<label for="odoo_save_token">Save my payment data</label>
|
||||
</div>
|
||||
<div class="pre_msg" t-field="acquirer.pre_msg" />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<t t-call="website_sale.total">
|
||||
<t t-set='extra_class' t-value='"col-sm-4 col-sm-offset-8 col-xs-8 col-xs-offset-4"'/>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
<div class="js_payment mb64 row" t-if="not website_sale_order.amount_total" id="payment_method">
|
||||
<div class="col-sm-12">
|
||||
<form target="_self" action="/shop/payment/validate" method="post" class="pull-right">
|
||||
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()" />
|
||||
<a style="width:127px;" class="btn btn-primary a-submit">
|
||||
<span t-if="order.amount_total > 0">Pay Now <span class="fa fa-long-arrow-right"></span></span>
|
||||
<span t-if="order.amount_total == 0">Confirm Order <span class="fa fa-long-arrow-right"></span></span>
|
||||
</a>
|
||||
</form>
|
||||
<div class="js_payment mb64 row" t-if="acquirers and website_sale_order.amount_total" id="payment_method">
|
||||
<div class="col-lg-5 col-sm-6">
|
||||
<h4>Payment Method:</h4>
|
||||
<ul class="list-unstyled">
|
||||
<t t-set="payment_methods_available" t-value="False"/>
|
||||
<t t-set="partner_country" t-value="website_sale_order and website_sale_order.partner_invoice_id.country_id"/>
|
||||
<t t-foreach="acquirers or []" t-as="acquirer">
|
||||
<li t-if="not acquirer.country_ids or partner_country in acquirer.country_ids">
|
||||
<label t-if="acquirer.button">
|
||||
<input t-att-value="acquirer.id" type="radio" name="acquirer" t-att-checked="acquirers[0] == acquirer" />
|
||||
<span t-field="acquirer.image_small" t-att-title="acquirer.name" t-options='{"widget": "image", "style":"max-width: 60px; display: inline-block"}'/>
|
||||
<span t-field="acquirer.name" />
|
||||
<span t-if="acquirer.fees_active">(processing fees apply)</span>
|
||||
</label>
|
||||
<t t-set="payment_methods_available" t-value="True"/>
|
||||
</li>
|
||||
</t>
|
||||
<li t-if="not payment_methods_available">
|
||||
<div class="alert alert-warning">
|
||||
<span>No payment gateway is available for your country</span>
|
||||
</div>
|
||||
</li>
|
||||
<li t-if="any(token for token in tokens if not token.acquirer_id.country_ids or partner_country in token.acquirer_id.country_ids)">
|
||||
<label>
|
||||
<input type="radio" name="acquirer" />
|
||||
<span class='fa fa-2x fa-credit-card'/>
|
||||
Saved Cards
|
||||
</label>
|
||||
|
||||
<div class="list-group">
|
||||
<t t-foreach='tokens' t-as='token'>
|
||||
<a t-if="not token.acquirer_id.country_ids or partner_country in token.acquirer_id.country_ids" class="list-group-item btn_payment_token" t-att-data-acquirer="token.acquirer_id.id" t-att-data-token='token.id'>
|
||||
<span class="js_radio fa fa-circle-o"></span>&nbsp;
|
||||
<t t-esc="token.name" />
|
||||
<t t-if="len(set(tokens.mapped('acquirer_id')))>1">
|
||||
(<t t-esc='token.acquirer_id.name'/>)
|
||||
</t>
|
||||
<span t-if="token.acquirer_id.fees_active">(processing fees apply)</span>
|
||||
</a>
|
||||
</t>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-lg-5 col-lg-offset-2 col-sm-6 text-right">
|
||||
<t t-foreach="acquirers or []" t-as="acquirer" id="acquirers_list">
|
||||
<div t-att-data-id="acquirer.id" class="oe_sale_acquirer_button hidden pull-right">
|
||||
<div t-raw="acquirer.button" />
|
||||
<div class="token_hide">
|
||||
<div t-if="acquirer.save_token == 'ask'">
|
||||
<input type="checkbox" name="odoo_save_token" id="odoo_save_token"/>
|
||||
<label for="odoo_save_token">Save my payment data</label>
|
||||
</div>
|
||||
<div class="pre_msg" t-field="acquirer.pre_msg" />
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
<div class="js_payment mb64 row" t-if="not website_sale_order.amount_total" id="payment_method">
|
||||
<div class="col-sm-12">
|
||||
<form target="_self" action="/shop/payment/validate" method="post" class="pull-right">
|
||||
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()" />
|
||||
<a style="width:127px;" class="btn btn-primary a-submit">
|
||||
<span t-if="order.amount_total > 0">Pay Now <span class="fa fa-long-arrow-right"></span></span>
|
||||
<span t-if="order.amount_total == 0">Confirm Order <span class="fa fa-long-arrow-right"></span></span>
|
||||
</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-lg-offset-1 col-sm-3 col-md-3 text-muted" id="right_column"/>
|
||||
<div class="clearfix" />
|
||||
<div class="oe_structure" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1438,6 +1439,27 @@
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="reduction_code_payment" inherit_id="website_sale.payment" active="True" customize_show="True" name="Coupon Code">
|
||||
<xpath expr="//div[@id='right_column']" position="inside">
|
||||
<h4>Coupon Code</h4>
|
||||
<p>
|
||||
Have a coupon code? Fill in this field and apply.
|
||||
</p>
|
||||
<t t-if="code_not_available" name="code_not_available">
|
||||
<p class="bg-warning">This promo code is not available</p>
|
||||
</t>
|
||||
<form t-if="website_sale_order and website_sale_order.website_order_line" action="/shop/pricelist_payment" method="post" class="mb32" name="coupon_code">
|
||||
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()" />
|
||||
<div class="input-group">
|
||||
<input name="promo" class="form-control" type="text" placeholder="code..." t-att-value="website_sale_order.pricelist_id.code or None" />
|
||||
<div class="input-group-btn">
|
||||
<a class="btn btn-default a-submit">Apply</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="payment_sale_note" inherit_id="payment" name="Accept Terms & Conditions" customize_show="True" active="False">
|
||||
<xpath expr="//t[@id='acquirers_list']" position="before">
|
||||
<div class="oe_accept_cgv_button">
|
||||
|
||||
Reference in New Issue
Block a user