19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:32:12 +01:00
parent 79f83631d5
commit 73afc09215
6267 changed files with 1534193 additions and 1130106 deletions

View file

@ -8,12 +8,8 @@ from odoo.exceptions import UserError
class MrpBom(models.Model):
_inherit = 'mrp.bom'
def toggle_active(self):
self.filtered(lambda bom: bom.active)._ensure_bom_is_free()
return super().toggle_active()
def write(self, vals):
if 'phantom' in self.mapped('type') and vals.get('type', 'phantom') != 'phantom':
if not vals.get('active', True) or ('phantom' in self.mapped('type') and vals.get('type', 'phantom') != 'phantom'):
self._ensure_bom_is_free()
return super().write(vals)
@ -24,13 +20,13 @@ class MrpBom(models.Model):
def _ensure_bom_is_free(self):
product_ids = []
for bom in self:
if bom.type != 'phantom':
if not bom.active or bom.type != 'phantom':
continue
product_ids += bom.product_id.ids or bom.product_tmpl_id.product_variant_ids.ids
if not product_ids:
return
lines = self.env['sale.order.line'].sudo().search([
('state', 'in', ('sale', 'done')),
('state', '=', 'sale'),
('invoice_status', 'in', ('no', 'to invoice')),
('product_id', 'in', product_ids),
('move_ids.state', '!=', 'cancel'),