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.

30 lines
1.2 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.http import request
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)
order = request.website.sale_get_order()
res.qcontext['no_pass_payment'] = False
if order.amount_total <= request.website.amount_limit:
res.qcontext['no_pass_payment'] = True
res.qcontext['amount_limit'] = request.website.amount_limit
return res
class WebsiteSale(WebsiteSale):
@http.route(['/shop/checkout'], type='http', auth="public", website=True, sitemap=False)
def checkout(self, **post):
order = request.website.sale_get_order()
if order.amount_total <= request.website.amount_limit:
return request.redirect('/shop/cart')
return super(WebsiteSale, self).checkout(**post)