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.
49 lines
2.3 KiB
49 lines
2.3 KiB
# Copyright 2021 Le Filament (<http://www.le-filament.com>)
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
|
|
from odoo import http
|
|
from odoo.addons.website_sale.controllers.main import WebsiteSale
|
|
from odoo.addons.website_coupon.controllers.main import WebsiteCoupon
|
|
|
|
|
|
class WebsiteCoupon(WebsiteCoupon):
|
|
|
|
@http.route(['/shop/cart'], type='http', auth="public", website=True, sitemap=False)
|
|
def cart(self, access_token=None, revive='', **post):
|
|
res = super(WebsiteCoupon, self).cart(access_token, revive, **post)
|
|
return res
|
|
|
|
|
|
class WebsiteSale(WebsiteSale):
|
|
|
|
@http.route(['/shop/cart/update_json'], type='json', auth="public", methods=['POST'], website=True, csrf=False)
|
|
def cart_update_json(self, product_id, line_id=None, add_qty=None, set_qty=None, display=True):
|
|
res = super(WebsiteSale, self).cart_update_json(product_id, line_id, add_qty, set_qty, display)
|
|
return res
|
|
|
|
@http.route(['/shop/cart/update'], type='http', auth="public", methods=['POST'], website=True, csrf=False)
|
|
def cart_update(self, product_id, add_qty=1, set_qty=0, **kw):
|
|
res = super(WebsiteSale, self).cart_update(product_id, add_qty, set_qty, **kw)
|
|
return res
|
|
# """This route is called when adding a product to cart (no options)."""
|
|
# sale_order = request.website.sale_get_order(force_create=True)
|
|
# if sale_order.state != 'draft':
|
|
# request.session['sale_order_id'] = None
|
|
# sale_order = request.website.sale_get_order(force_create=True)
|
|
#
|
|
# product_custom_attribute_values = None
|
|
# if kw.get('product_custom_attribute_values'):
|
|
# product_custom_attribute_values = json.loads(kw.get('product_custom_attribute_values'))
|
|
#
|
|
# no_variant_attribute_values = None
|
|
# if kw.get('no_variant_attribute_values'):
|
|
# no_variant_attribute_values = json.loads(kw.get('no_variant_attribute_values'))
|
|
#
|
|
# sale_order._cart_update(
|
|
# product_id=int(product_id),
|
|
# add_qty=add_qty,
|
|
# set_qty=set_qty,
|
|
# product_custom_attribute_values=product_custom_attribute_values,
|
|
# no_variant_attribute_values=no_variant_attribute_values
|
|
# )
|
|
# return request.redirect("/shop/cart")
|