Steps to reproduce: - Create a storable kit product - Update on hand quantity: only the components are displayed(correct behavior) - In Inventory tab open Inventory Adjustement - Possible to edit kit quantity Bug: In the product tab when trying to update qty the kit product is replaced with its components instead but it is still Possible to edit kit quantity directly in the inventory app Fix: introduced python constraint to prevent user from directly editing the kit product qty in master in standard just display a warning opw-3681703 closes odoo/odoo#160978 X-original-commit: ba81d4ef64933dc025c7a473456c5c056ed69aac Signed-off-by: William Henrotin (whe) <whe@odoo.com> Signed-off-by: Walid Hanniche (waha) <waha@odoo.com>
18 lines
687 B
Python
18 lines
687 B
Python
from odoo import models, _
|
|
from odoo.exceptions import RedirectWarning
|
|
|
|
|
|
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"),
|
|
)
|
|
return super().action_apply_inventory()
|