summaryrefslogtreecommitdiff
path: root/addons/mrp
diff options
context:
space:
mode:
authorWilliam Henrotin <whe@odoo.com>2020-11-19 14:54:48 +0000
committerWilliam Henrotin <whe@odoo.com>2020-11-25 16:51:27 +0000
commit49b965eb1ec6a7ec6c07fa643cc6ae35ee8b5d91 (patch)
tree78434cd2a3c0bec201c991acaa9c1d6564e1ebcb /addons/mrp
parent1c8ca358d75c9fe00631731d5061674c0a3a040b (diff)
[FIX] mrp: open component quantity for kit
The 'On Hand' button triggers action_open_quants on product model. It do not explode the kit into its component closes odoo/odoo#62354 Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
Diffstat (limited to 'addons/mrp')
-rw-r--r--addons/mrp/models/product.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/addons/mrp/models/product.py b/addons/mrp/models/product.py
index bc2bb215f37..266d250d1a3 100644
--- a/addons/mrp/models/product.py
+++ b/addons/mrp/models/product.py
@@ -205,3 +205,18 @@ class ProductProduct(models.Model):
action = self.product_tmpl_id.action_view_mos()
action['domain'] = [('state', '=', 'done'), ('product_id', 'in', self.ids)]
return action
+
+ def action_open_quants(self):
+ bom_kits = {}
+ for product in self:
+ bom = self.env['mrp.bom']._bom_find(product=product, bom_type='phantom')
+ if bom:
+ bom_kits[product] = bom
+ components = self - self.env['product.product'].concat(*list(bom_kits.keys()))
+ for product in bom_kits:
+ boms, bom_sub_lines = bom_kits[product].explode(product, 1)
+ components |= self.env['product.product'].concat(*[l[0].product_id for l in bom_sub_lines])
+ res = super(ProductProduct, components).action_open_quants()
+ if bom_kits:
+ res['context']['single_product'] = False
+ return res