From bf3eed8669034b20fbb18fe9a6d569662ebd0e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20G=C3=B6ttsch?= Date: Wed, 27 Aug 2025 12:32:52 +0200 Subject: [PATCH] [FIX] nfu_ecommerce: Drop session if SO belongs to another website (Odoo 16 bug) --- nfu_ecommerce/README.rst | 1 + nfu_ecommerce/__manifest__.py | 2 +- nfu_ecommerce/models/website.py | 19 +++++++++++++++++++ nfu_ecommerce/readme/HISTORY.rst | 3 ++- nfu_ecommerce/static/description/index.html | 2 ++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/nfu_ecommerce/README.rst b/nfu_ecommerce/README.rst index 50f90e3..1101e9a 100644 --- a/nfu_ecommerce/README.rst +++ b/nfu_ecommerce/README.rst @@ -54,6 +54,7 @@ Changelog :1.4.0: Add credit warning and avoid debts option :1.4.1: Add credit to portal details :1.4.2: Catch unescaped float values +:1.4.3: Drop session if SO belongs to another website (Odoo 16 bug) Bug Tracker =========== diff --git a/nfu_ecommerce/__manifest__.py b/nfu_ecommerce/__manifest__.py index 415a840..f761d29 100644 --- a/nfu_ecommerce/__manifest__.py +++ b/nfu_ecommerce/__manifest__.py @@ -4,7 +4,7 @@ "author": "BAKEUP", "website": "https://www.bakeup.org", "category": "website", - "version": "16.0.1.4.2", + "version": "16.0.1.4.3", "depends": [ "sale_product_configurator", "website_sale", diff --git a/nfu_ecommerce/models/website.py b/nfu_ecommerce/models/website.py index 3ed6649..0fcd52f 100644 --- a/nfu_ecommerce/models/website.py +++ b/nfu_ecommerce/models/website.py @@ -1,4 +1,5 @@ from odoo import fields, models +from odoo.http import request class Website(models.Model): @@ -10,3 +11,21 @@ class Website(models.Model): help="When the credit of a customer is lower than the warning level the credit is shown in red on the website.", ) avoid_depts = fields.Boolean(string="Avoid depths") + + def sale_get_order(self, force_create=False, update_pricelist=False): + """Override to clean sale_order_id if so belongs to another website""" + self.ensure_one() + + self = self.with_company(self.company_id) + SaleOrder = self.env["sale.order"].sudo() + + sale_order_id = request.session.get("sale_order_id") + + if sale_order_id: + sale_order = SaleOrder.browse(sale_order_id).exists() + if sale_order and sale_order.website_id != self: + request.session.pop("sale_order_id") + + return super().sale_get_order( + force_create=force_create, update_pricelist=update_pricelist + ) diff --git a/nfu_ecommerce/readme/HISTORY.rst b/nfu_ecommerce/readme/HISTORY.rst index 6191ea1..f653eaf 100644 --- a/nfu_ecommerce/readme/HISTORY.rst +++ b/nfu_ecommerce/readme/HISTORY.rst @@ -9,4 +9,5 @@ :1.3.2: Add decimal to ribbon :1.4.0: Add credit warning and avoid debts option :1.4.1: Add credit to portal details -:1.4.2: Catch unescaped float values \ No newline at end of file +:1.4.2: Catch unescaped float values +:1.4.3: Drop session if SO belongs to another website (Odoo 16 bug) \ No newline at end of file diff --git a/nfu_ecommerce/static/description/index.html b/nfu_ecommerce/static/description/index.html index 7fb8fb6..9debf8a 100644 --- a/nfu_ecommerce/static/description/index.html +++ b/nfu_ecommerce/static/description/index.html @@ -425,6 +425,8 @@ adjustes the uom quantitiy 1.4.2:Catch unescaped float values +1.4.3:Drop session if SO belongs to another website (Odoo 16 bug) +