[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) <vfe@odoo.com>
This commit is contained in:
committed by
Victor Feyens
parent
389856bcd9
commit
65e3bb5592
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user