From 65e3bb5592fc05a4eebe9159a45c741d2766aa34 Mon Sep 17 00:00:00 2001 From: "Levi Siuzdak (sile)" Date: Tue, 13 Feb 2024 17:39:34 +0100 Subject: [PATCH] [FIX] product: use sale order company for catalog Versions -------- - 17.0+ Steps ----- 1. Create a new company; 2. switch to it via the selector; 3. create a new product specific to the company; 4. create a sale order; 5. open the catalog via a sale order line. Issue ----- Access error Cause ----- The catalog controller does not receive the user context, therefore fallbacking on the default user context, with the main company of the user. Accessing a product from another company will fail and raise an AccessError. Solution -------- Make sure that catalog requests are done in the company of the order, the information is available and it makes no sense to use another company for those requests anyway. Also adds the missing license in the catalog mixin. opw-3690226 closes odoo/odoo#153915 Signed-off-by: Victor Feyens (vfe) --- addons/product/controllers/catalog.py | 8 ++++++-- addons/product/models/product_catalog_mixin.py | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/product/controllers/catalog.py b/addons/product/controllers/catalog.py index f0bb0e0d4ff..6531cffc439 100644 --- a/addons/product/controllers/catalog.py +++ b/addons/product/controllers/catalog.py @@ -25,7 +25,9 @@ class ProductCatalogController(Controller): } """ order = request.env[res_model].browse(order_id) - return order._get_product_catalog_order_line_info(product_ids, **kwargs) + return order.with_company(order.company_id)._get_product_catalog_order_line_info( + product_ids, **kwargs, + ) @route('/product/catalog/update_order_line_info', auth='user', type='json') def product_catalog_update_order_line_info(self, res_model, order_id, product_id, quantity=0, **kwargs): @@ -39,4 +41,6 @@ class ProductCatalogController(Controller): :rtype: float """ order = request.env[res_model].browse(order_id) - return order._update_order_line_info(product_id, quantity, **kwargs) + return order.with_company(order.company_id)._update_order_line_info( + product_id, quantity, **kwargs, + ) diff --git a/addons/product/models/product_catalog_mixin.py b/addons/product/models/product_catalog_mixin.py index 16d0e4b0ce4..95a372364d7 100644 --- a/addons/product/models/product_catalog_mixin.py +++ b/addons/product/models/product_catalog_mixin.py @@ -1,5 +1,6 @@ -from odoo import _, models +# Part of Odoo. See LICENSE file for full copyright and licensing details. +from odoo import _, models class ProductCatalogMixin(models.AbstractModel):