From a1ad6375efea21fd41cd15cb6749f409f17db123 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 9 Nov 2017 13:00:47 +0100 Subject: [PATCH] [FIX] stock: reordering rules on service 1. Create a stockable product 2. Create a reordering rule 3. Ooops, change stockable into service 4. Run scheduler Odoo created procurement for service products. We prevent changing the product type if there are active reordering rules. We could have silently skipped these products when running the scheduler (in `_get_orderpoint_domain`), but that would have potentially broke existing installations incorrectly set up. opw-781128 --- addons/stock/models/product.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index d581fde2855..2a0e96f58dd 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -505,6 +505,8 @@ class ProductTemplate(models.Model): done_moves = self.env['stock.move'].search([('product_id', 'in', updated.mapped('product_variant_ids').ids)], limit=1) if done_moves: raise UserError(_("You can not change the unit of measure of a product that has already been used in a done stock move. If you need to change the unit of measure, you may deactivate this product.")) + if 'type' in vals and vals['type'] != 'product' and sum(self.mapped('nbr_reordering_rules')) != 0: + raise UserError(_('You still have some active reordering rules on this product. Please archive or delete them first.')) return super(ProductTemplate, self).write(vals) @api.multi