This question has been flagged

Hello,

I created a select list in the page of product shop. It gives the user the choice of either:
1) - Add to Cart and continue shopping. Here the customer will add the product to the cart and will be authentically directed to the store.
2) - Add to cart and finalize your purchases. Here the customer will add the product to the cart and will be automatically redirected to the Checkout page.


But the both button redirects me on the store. And when i put "position="replace", i have an error. Can you tell where is the problem here and how can i correct my main.py to redirect the second button in Checkout page.Thank you.

So, this is my work in Odoo 8 :

I tried to create a file
xml like this :

<xpath expr="//a[@id='add_to_cart']" position="after">
<div class="custom-select" style="width:200px;">
<select>
<option value="0">Add to cart and:</option>
<option value="#" id="add_to_cart" class="btn btn-primary btn-lg mt8 js_check_product a-submit" >Continue Shoping</option>
<option value="/shop/checkout" id="add_to_cart" class="btn btn-primary btn-lg mt8 js_check_product a-submit">Finish Shoping</option>
</select>
</div>
</xpath>

This is my main.py in the folder controllers :

# -*- coding: utf-8 -*-
import werkzeug
from openerp import http
from openerp.http import request
class website_sale(http.Controller):
@http.route(['/shop/cart/update'], type='http', auth="public", methods=['POST'], website=True)
def cart_update(self, product_id, add_qty=1, set_qty=0, **kw):
cr, uid, context = request.cr, request.uid, request.context
request.website.sale_get_order(force_create=1)._cart_update(product_id=int(product_id), add_qty=float(add_qty), set_qty=float(set_qty))
return request.redirect("/shop")
Avatar
Discard