Skip to content
Snippets Groups Projects
Commit fad9d559 authored by Richard deMeester's avatar Richard deMeester
Browse files

[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#134807

X-original-commit: 42674464
Signed-off-by: default avatarTiffany Chang (tic) <tic@odoo.com>
parent 91e4d9a5
No related branches found
No related tags found
No related merge requests found
......@@ -870,7 +870,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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment