Skip to content
Snippets Groups Projects
Commit e8bb4a50 authored by PNO's avatar PNO
Browse files

[FIX] stock: multi-company check to change product type

On the ticket https://github.com/odoo/odoo/pull/101547

 a constraint was added to prevent the user from changing the product type if some moves have already been made.
This was done because changing the type creates inconsistencies (like breaking the valuation).
However, it currently only checks if there are moves on the current company, when it should check in all companies.
This can be fixed by adding sudo.

closes odoo/odoo#106301

Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
parent d2ed2914
Branches
Tags
No related merge requests found
......@@ -739,7 +739,7 @@ class ProductTemplate(models.Model):
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.'))
if any('type' in vals and vals['type'] != prod_tmpl.type for prod_tmpl in self):
existing_done_move_lines = self.env['stock.move.line'].search([
existing_done_move_lines = self.env['stock.move.line'].sudo().search([
('product_id', 'in', self.mapped('product_variant_ids').ids),
('state', '=', 'done'),
], limit=1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment