You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
2.3 KiB

3 years ago
  1. # Copyright 2021 Le Filament (<http://www.le-filament.com>)
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo import http
  4. from odoo.addons.website_sale.controllers.main import WebsiteSale
  5. from odoo.addons.website_coupon.controllers.main import WebsiteCoupon
  6. class WebsiteCoupon(WebsiteCoupon):
  7. @http.route(['/shop/cart'], type='http', auth="public", website=True, sitemap=False)
  8. def cart(self, access_token=None, revive='', **post):
  9. res = super(WebsiteCoupon, self).cart(access_token, revive, **post)
  10. return res
  11. class WebsiteSale(WebsiteSale):
  12. @http.route(['/shop/cart/update_json'], type='json', auth="public", methods=['POST'], website=True, csrf=False)
  13. def cart_update_json(self, product_id, line_id=None, add_qty=None, set_qty=None, display=True):
  14. res = super(WebsiteSale, self).cart_update_json(product_id, line_id, add_qty, set_qty, display)
  15. return res
  16. @http.route(['/shop/cart/update'], type='http', auth="public", methods=['POST'], website=True, csrf=False)
  17. def cart_update(self, product_id, add_qty=1, set_qty=0, **kw):
  18. res = super(WebsiteSale, self).cart_update(product_id, add_qty, set_qty, **kw)
  19. return res
  20. # """This route is called when adding a product to cart (no options)."""
  21. # sale_order = request.website.sale_get_order(force_create=True)
  22. # if sale_order.state != 'draft':
  23. # request.session['sale_order_id'] = None
  24. # sale_order = request.website.sale_get_order(force_create=True)
  25. #
  26. # product_custom_attribute_values = None
  27. # if kw.get('product_custom_attribute_values'):
  28. # product_custom_attribute_values = json.loads(kw.get('product_custom_attribute_values'))
  29. #
  30. # no_variant_attribute_values = None
  31. # if kw.get('no_variant_attribute_values'):
  32. # no_variant_attribute_values = json.loads(kw.get('no_variant_attribute_values'))
  33. #
  34. # sale_order._cart_update(
  35. # product_id=int(product_id),
  36. # add_qty=add_qty,
  37. # set_qty=set_qty,
  38. # product_custom_attribute_values=product_custom_attribute_values,
  39. # no_variant_attribute_values=no_variant_attribute_values
  40. # )
  41. # return request.redirect("/shop/cart")