-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
86 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
from . import models | ||
from . import controllers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
from . import main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from odoo import http | ||
from odoo.http import request | ||
|
||
from odoo.addons.website_sale.controllers.main import WebsiteSale | ||
|
||
|
||
class WebsiteSaleRestrictSEPADD(WebsiteSale): | ||
@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, | ||
product_custom_attribute_values=None, | ||
no_variant_attribute_values=None, | ||
express=False, | ||
**kwargs | ||
): | ||
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) | ||
|
||
warning = sale_order.check_product_compatibility(int(product_id)) | ||
|
||
request.session["website_sale_cart_warning"] = warning | ||
|
||
if warning: | ||
return request.redirect("/shop/cart") | ||
|
||
return super().cart_update( | ||
product_id=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, | ||
express=express, | ||
**kwargs | ||
) | ||
|
||
@http.route(["/shop/cart"], type="http", auth="public", website=True, sitemap=False) | ||
def cart(self, access_token=None, revive="", **post): | ||
warning = request.session["website_sale_cart_warning"] | ||
del request.session["website_sale_cart_warning"] | ||
response = super().cart(access_token=access_token, revive=revive, **post) | ||
response.qcontext["website_sale_cart_warning"] = warning | ||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters