[FIX] mrp: prevent kit product quant update

using sudo().is_kits to account for user not having access
to the bom module and boms in different companies

closes odoo/odoo#162830

X-original-commit: badd0a6dce90cc103ebc2c193e47da3f753f80a6
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Walid Hanniche (waha) <waha@odoo.com>
This commit is contained in:
Walid
2024-04-22 17:04:39 +00:00
parent de24389b43
commit 1882d8f89f
+6 -8
View File
@@ -6,12 +6,10 @@ class StockQuant(models.Model):
_inherit = 'stock.quant'
def action_apply_inventory(self):
bom_kits = self.env['mrp.bom']._bom_find(self.product_id, bom_type='phantom')
for record in self:
if record.product_id in bom_kits:
raise RedirectWarning(
_('You should update the components quantity instead of directly updating the quantity of the kit product.'),
self.env.ref('stock.action_view_inventory_tree').id,
_("Return to Inventory"),
)
if self.sudo().product_id.filtered("is_kits"):
raise RedirectWarning(
_('You should update the components quantity instead of directly updating the quantity of the kit product.'),
self.env.ref('stock.action_view_inventory_tree').id,
_("Return to Inventory"),
)
return super().action_apply_inventory()