From 5d75d07bad44bd542bb82025e465c798326f4b92 Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Fri, 13 Sep 2019 12:18:53 +0000 Subject: [PATCH] [FIX] mrp: product quantities by company Before this commit, the product/product template computed mrp quantity fields wasn't computed by active company but for all companies. So, set `compute_sudo` on false for the different computed mrp quantity fields of products and product templates to avoid to search with sudo active and to search by company. --- addons/mrp/models/product.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/addons/mrp/models/product.py b/addons/mrp/models/product.py index ea2f8084d5f..18b8981a522 100644 --- a/addons/mrp/models/product.py +++ b/addons/mrp/models/product.py @@ -11,9 +11,12 @@ class ProductTemplate(models.Model): bom_line_ids = fields.One2many('mrp.bom.line', 'product_tmpl_id', 'BoM Components') bom_ids = fields.One2many('mrp.bom', 'product_tmpl_id', 'Bill of Materials') - bom_count = fields.Integer('# Bill of Material', compute='_compute_bom_count') - used_in_bom_count = fields.Integer('# of BoM Where is Used', compute='_compute_used_in_bom_count') - mrp_product_qty = fields.Float('Manufactured', compute='_compute_mrp_product_qty') + bom_count = fields.Integer('# Bill of Material', + compute='_compute_bom_count', compute_sudo=False) + used_in_bom_count = fields.Integer('# of BoM Where is Used', + compute='_compute_used_in_bom_count', compute_sudo=False) + mrp_product_qty = fields.Float('Manufactured', + compute='_compute_mrp_product_qty', compute_sudo=False) produce_delay = fields.Float( 'Manufacturing Lead Time', default=0.0, help="Average lead time in days to manufacture this product. In the case of multi-level BOM, the manufacturing lead times of the components will be added.") @@ -52,9 +55,12 @@ class ProductProduct(models.Model): variant_bom_ids = fields.One2many('mrp.bom', 'product_id', 'BOM Product Variants') bom_line_ids = fields.One2many('mrp.bom.line', 'product_id', 'BoM Components') - bom_count = fields.Integer('# Bill of Material', compute='_compute_bom_count') - used_in_bom_count = fields.Integer('# BoM Where Used', compute='_compute_used_in_bom_count') - mrp_product_qty = fields.Float('Manufactured', compute='_compute_mrp_product_qty') + bom_count = fields.Integer('# Bill of Material', + compute='_compute_bom_count', compute_sudo=False) + used_in_bom_count = fields.Integer('# BoM Where Used', + compute='_compute_used_in_bom_count', compute_sudo=False) + mrp_product_qty = fields.Float('Manufactured', + compute='_compute_mrp_product_qty', compute_sudo=False) def _compute_bom_count(self): for product in self: