main.py 810 B

1234567891011121314151617
  1. # -*- coding: utf-8 -*-
  2. from openerp import http
  3. from openerp.http import request
  4. from openerp.addons.website.models.website import slug
  5. from openerp.addons.website_sale.controllers.main import website_sale
  6. class WebsiteSale(website_sale):
  7. @http.route(['/shop/cart/update'], type='http', auth="public", methods=['POST'], website=True)
  8. def cart_update(self, product_id, add_qty=1, set_qty=0, **kw):
  9. cr, uid, context, registry = request.cr, request.uid, request.context, request.registry
  10. res = super(WebsiteSale, self).cart_update(product_id, add_qty, set_qty, **kw)
  11. product = registry.get('product.product').browse(cr, uid, int(product_id))
  12. back_to_product_href = "/shop/product/" + slug(product.product_tmpl_id)
  13. return request.redirect(back_to_product_href)