[FIX] mrp: prevent kit product quant update
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>
This commit is contained in:
@@ -4712,6 +4712,12 @@ msgstr ""
|
||||
msgid "Routing"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp
|
||||
#: code:addons/mrp/models/stock_quant.py:0
|
||||
#, python-format
|
||||
msgid "Return to Inventory"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp
|
||||
#: model:ir.model.fields,field_description:mrp.field_mrp_workcenter__routing_line_ids
|
||||
msgid "Routing Lines"
|
||||
@@ -6758,6 +6764,13 @@ msgstr ""
|
||||
msgid "You should provide a lot number for the final product."
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp
|
||||
#. odoo-python
|
||||
#: code:addons/mrp/models/stock_quant.py:0
|
||||
#, python-format
|
||||
msgid "You should update the components quantity instead of directly updating the quantity of the kit product."
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp
|
||||
#: model:ir.model.fields.selection,name:mrp.selection__stock_picking_type__done_mrp_lot_label_to_print__zpl
|
||||
#: model:ir.model.fields.selection,name:mrp.selection__stock_picking_type__generated_mrp_lot_label_to_print__zpl
|
||||
|
||||
@@ -19,3 +19,4 @@ from . import stock_lot
|
||||
from . import stock_rule
|
||||
from . import stock_scrap
|
||||
from . import stock_warehouse
|
||||
from . import stock_quant
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user