[FIX] stock: change UOM on product block - multi company
There is code to block the UOM changing if there are done moves. Because it searches in non-sudo mode, it does NOT currently stop you changing the UOM if the product has moves in a different company. closes odoo/odoo#134900 X-original-commit: 426744646c25e8c2b17e3a50de186bd91b5e645f Signed-off-by: Tiffany Chang (tic) <tic@odoo.com>
This commit is contained in:
@@ -862,7 +862,7 @@ class ProductTemplate(models.Model):
|
||||
if 'uom_id' in vals:
|
||||
new_uom = self.env['uom.uom'].browse(vals['uom_id'])
|
||||
updated = self.filtered(lambda template: template.uom_id != new_uom)
|
||||
done_moves = self.env['stock.move'].search([('product_id', 'in', updated.with_context(active_test=False).mapped('product_variant_ids').ids)], limit=1)
|
||||
done_moves = self.env['stock.move'].sudo().search([('product_id', 'in', updated.with_context(active_test=False).mapped('product_variant_ids').ids)], limit=1)
|
||||
if done_moves:
|
||||
raise UserError(_("You cannot change the unit of measure as there are already stock moves for this product. If you want to change the unit of measure, you should rather archive this product and create a new one."))
|
||||
if 'type' in vals and vals['type'] != 'product' and sum(self.mapped('nbr_reordering_rules')) != 0:
|
||||
|
||||
Reference in New Issue
Block a user