[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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user