[FIX] website_sale: remove duplicated code for coupon and call from enterprise route
/shop/pricelist_payment was only defined in coupon module from enterprise. Add optional r param in pricelist controller to allow to redirect into a specific page
This commit is contained in:
@@ -322,12 +322,13 @@ class WebsiteSale(http.Controller):
|
||||
|
||||
@http.route(['/shop/pricelist'], type='http', auth="public", website=True)
|
||||
def pricelist(self, promo, **post):
|
||||
redirect = post.get('r', '/shop/cart')
|
||||
pricelist = request.env['product.pricelist'].sudo().search([('code', '=', promo)], limit=1)
|
||||
if pricelist and not request.website.is_pricelist_available(pricelist.id):
|
||||
return request.redirect("/shop/cart?code_not_available=1")
|
||||
if not pricelist or (pricelist and not request.website.is_pricelist_available(pricelist.id)):
|
||||
return request.redirect("%s?code_not_available=1" % redirect)
|
||||
|
||||
request.website.sale_get_order(code=promo)
|
||||
return request.redirect("/shop/cart")
|
||||
return request.redirect(redirect)
|
||||
|
||||
@http.route(['/shop/cart'], type='http', auth="public", website=True)
|
||||
def cart(self, **post):
|
||||
@@ -353,9 +354,6 @@ class WebsiteSale(http.Controller):
|
||||
if post.get('type') == 'popover':
|
||||
return request.render("website_sale.cart_popover", values)
|
||||
|
||||
if post.get('code_not_available'):
|
||||
values['code_not_available'] = post.get('code_not_available')
|
||||
|
||||
return request.render("website_sale.cart", values)
|
||||
|
||||
@http.route(['/shop/cart/update'], type='http', auth="public", methods=['POST'], website=True, csrf=False)
|
||||
|
||||
@@ -629,3 +629,8 @@ a.no-decoration {
|
||||
.break-word {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
#coupon_box form {
|
||||
max-width: 300px;
|
||||
}
|
||||
|
||||
|
||||
@@ -550,3 +550,6 @@ a.no-decoration
|
||||
|
||||
.break-word
|
||||
word-wrap: break-word
|
||||
|
||||
#coupon_box form
|
||||
max-width: 300px
|
||||
|
||||
@@ -1029,24 +1029,31 @@
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id='coupon_form' name='Coupon form'>
|
||||
<t t-if="request.params.get('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" t-att-action="'/shop/pricelist%s' % (redirect and '?r=' + redirect or '')"
|
||||
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>
|
||||
</template>
|
||||
|
||||
<template id="reduction_code" inherit_id="website_sale.cart" active="False" 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 t-call='website_sale.coupon_form'>
|
||||
<t t-set='redirect'>/shop/cart</t>
|
||||
</t>
|
||||
<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" />
|
||||
<div class="input-group-btn">
|
||||
<a class="btn btn-default a-submit">Apply</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
@@ -1350,15 +1357,24 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-sm-4 col-md-4 text-muted" id="coupon_box"/>
|
||||
<div class="col-md-12">
|
||||
<div class="col-lg-5 col-sm-6 col-xs-12 text-muted" id="coupon_box">
|
||||
<t t-if="request.env.ref('website_sale.reduction_code').active">
|
||||
<p>
|
||||
Have a coupon code? Fill in this field and apply.
|
||||
</p>
|
||||
<t t-call='website_sale.coupon_form'>
|
||||
<t t-set='redirect'>/shop/payment</t>
|
||||
</t>
|
||||
</t>
|
||||
</div>
|
||||
<t t-call="website_sale.total">
|
||||
<t t-set='extra_class' t-value='"col-lg-7 col-sm-8 col-md-8"'/>
|
||||
<t t-set='extra_class' t-value='"col-lg-7 col-sm-6 col-xs-12"'/>
|
||||
</t>
|
||||
</div>
|
||||
<div class="clearfix" />
|
||||
<div class="oe_structure" />
|
||||
<div class="js_payment mb64 row" t-if="acquirers and website_sale_order.amount_total" id="payment_method">
|
||||
<div class="js_payment mb64 col-md-12 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">
|
||||
@@ -1439,26 +1455,6 @@
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="reduction_code_payment" inherit_id="website_sale.payment" active="False" customize_show="True" name="Coupon Code">
|
||||
<xpath expr="//div[@id='coupon_box']" position="inside">
|
||||
<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