From 1ad8b88fbaa770feadbfa0b10c0c302da5ec8031 Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Fri, 13 Sep 2019 12:41:16 +0000 Subject: [PATCH] [FIX] stock: reordering rules count by company Before this commit, the reordering rules computed quantity fields wasn't computed by active company but for all companies. So, set `compute_sudo` on false for `nbr_reordering_rules`, `reordering_min_qty`, `reordering_max_qty` of products and product templates to avoid to search with sudo active and to search by company. closes odoo/odoo#36856 Signed-off-by: Simon Lejeune (sle) --- addons/stock/models/product.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index 5e91b2eb2b5..3bd67a33ffe 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -83,9 +83,12 @@ class Product(models.Model): "Location with 'internal' type.") orderpoint_ids = fields.One2many('stock.warehouse.orderpoint', 'product_id', 'Minimum Stock Rules') - nbr_reordering_rules = fields.Integer('Reordering Rules', compute='_compute_nbr_reordering_rules') - reordering_min_qty = fields.Float(compute='_compute_nbr_reordering_rules') - reordering_max_qty = fields.Float(compute='_compute_nbr_reordering_rules') + nbr_reordering_rules = fields.Integer('Reordering Rules', + compute='_compute_nbr_reordering_rules', compute_sudo=False) + reordering_min_qty = fields.Float( + compute='_compute_nbr_reordering_rules', compute_sudo=False) + reordering_max_qty = fields.Float( + compute='_compute_nbr_reordering_rules', compute_sudo=False) putaway_rule_ids = fields.One2many('stock.putaway.rule', 'product_id', 'Putaway Rules') @api.depends('stock_move_ids.product_qty', 'stock_move_ids.state') @@ -594,10 +597,12 @@ class ProductTemplate(models.Model): 'stock.location.route', 'stock_route_product', 'product_id', 'route_id', 'Routes', domain=[('product_selectable', '=', True)], help="Depending on the modules installed, this will allow you to define the route of the product: whether it will be bought, manufactured, replenished on order, etc.") - nbr_reordering_rules = fields.Integer('Reordering Rules', compute='_compute_nbr_reordering_rules') - # TDE FIXME: really used ? - reordering_min_qty = fields.Float(compute='_compute_nbr_reordering_rules') - reordering_max_qty = fields.Float(compute='_compute_nbr_reordering_rules') + nbr_reordering_rules = fields.Integer('Reordering Rules', + compute='_compute_nbr_reordering_rules', compute_sudo=False) + reordering_min_qty = fields.Float( + compute='_compute_nbr_reordering_rules', compute_sudo=False) + reordering_max_qty = fields.Float( + compute='_compute_nbr_reordering_rules', compute_sudo=False) # TDE FIXME: seems only visible in a view - remove me ? route_from_categ_ids = fields.Many2many( relation="stock.location.route", string="Category Routes",