From 73c423be45133d927d92b67cf89c588ee904b55d Mon Sep 17 00:00:00 2001 From: Lois Rilo Date: Wed, 15 Jan 2020 16:09:27 +0100 Subject: [PATCH 1/2] [11.0][FIX] mrp_multi_level: when triggered from a different company, the recomputation of supplier can raise an access error. Using recompute_sudo avoids this problem. --- mrp_multi_level/models/product_mrp_area.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mrp_multi_level/models/product_mrp_area.py b/mrp_multi_level/models/product_mrp_area.py index a73901bd6..6bbde65e6 100644 --- a/mrp_multi_level/models/product_mrp_area.py +++ b/mrp_multi_level/models/product_mrp_area.py @@ -34,6 +34,7 @@ class ProductMRPArea(models.Model): readonly=True, related='product_id.product_tmpl_id', store=True, + compute_sudo=True, ) location_id = fields.Many2one( related="mrp_area_id.location_id", @@ -75,11 +76,11 @@ class ProductMRPArea(models.Model): main_supplier_id = fields.Many2one( comodel_name='res.partner', string='Main Supplier', compute='_compute_main_supplier', store=True, - index=True, + index=True, compute_sudo=True, ) main_supplierinfo_id = fields.Many2one( comodel_name='product.supplierinfo', string='Supplier Info', - compute='_compute_main_supplier', store=True, + compute='_compute_main_supplier', store=True, compute_sudo=True, ) supply_method = fields.Selection( selection=[('buy', 'Buy'), @@ -172,7 +173,9 @@ class ProductMRPArea(models.Model): """Simplified and similar to procurement.rule logic.""" for rec in self.filtered(lambda r: r.supply_method == 'buy'): suppliers = rec.product_id.seller_ids.filtered( - lambda r: (not r.product_id or r.product_id == rec.product_id)) + lambda r: (not r.product_id or r.product_id == rec.product_id) + and (not r.company_id or r.company_id == rec.company_id) + ) if not suppliers: continue rec.main_supplierinfo_id = suppliers[0] From 59b4420596385cc6839d4b800903bab897fb26a9 Mon Sep 17 00:00:00 2001 From: Lois Rilo Date: Thu, 6 Feb 2020 08:55:29 +0100 Subject: [PATCH 2/2] [FIX] mrp_multi_level: company in the search view move to the last position. It isn't the most common filter used. --- mrp_multi_level/views/mrp_inventory_views.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mrp_multi_level/views/mrp_inventory_views.xml b/mrp_multi_level/views/mrp_inventory_views.xml index 438c82175..66f56b6e4 100644 --- a/mrp_multi_level/views/mrp_inventory_views.xml +++ b/mrp_multi_level/views/mrp_inventory_views.xml @@ -87,10 +87,10 @@ search - +