0

I created a select option that 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")

Can you correct me please? I think my problem is with main.py...

  • could you post your error log? – aekis.dev Sep 13 '18 at 11:22
  • This is the error log: "Vue `Select Quantity` [view_id: 1165, xml_id: website_sale.product_quantity, model: n/a, parent_id: 1164] " while parsing None:14, near" But, the real problem is that the two values redirect in Shop page. I need only "Finish Shoping" redirect to the Checkout Page. – Dalila Hannouche Sep 13 '18 at 11:29
  • Sorry but I have no enough info to have an idea of the problem – aekis.dev Sep 13 '18 at 11:44

0 Answers0