From 1f3cbfd7ca900e1e967e80d3a2576ee606dd936b Mon Sep 17 00:00:00 2001 From: "Adrien Widart (awt)" Date: Fri, 28 Oct 2022 12:41:42 +0000 Subject: [PATCH] [FIX] mrp: hide smart buttons for kits When a kit template has several variants, the on hand quantity can be incorrect. To reproduce the issue: 1. Create two products P_compo, P_kit: - P_kit: - Storable - Variants: - Color (White, Black) - P_compo: - Storable 2. Update the on hand quantity of P_compo: 10 3. Create two BoMs: - BoM01: - Product: P_kit - Variant: Black - Type: Kit - Components: 1 x P_compo - BoM02: - Product: P_kit - Variant: White - Type: Kit - Components: 2 x P_compo 4. Open the form view of the template P_kit Error: it displays "15 units on hand", which is impossible (there are only 10 P_compo available) Since it is difficult to determine the expected value, a decision has been made: hide these smart buttons if a template has more than one variant and if at least one of the variants is a kit. OPW-2645299 OPW-2678400 OPW-3076502 closes odoo/odoo#108284 X-original-commit: cf3b83d6a48c080d900d9cf343e4012be718c79d Signed-off-by: William Henrotin (whe) Signed-off-by: Adrien Widart --- addons/mrp/models/product.py | 2 +- addons/stock/views/product_views.xml | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/mrp/models/product.py b/addons/mrp/models/product.py index 6ef0e134f21..45cf8b0fbff 100644 --- a/addons/mrp/models/product.py +++ b/addons/mrp/models/product.py @@ -53,7 +53,7 @@ class ProductTemplate(models.Model): super()._compute_show_qty_status_button() for template in self: if template.is_kits: - template.show_on_hand_qty_status_button = True + template.show_on_hand_qty_status_button = template.product_variant_count <= 1 template.show_forecasted_qty_status_button = False def _compute_used_in_bom_count(self): diff --git a/addons/stock/views/product_views.xml b/addons/stock/views/product_views.xml index 328d4e7925f..dbbd5b878b3 100644 --- a/addons/stock/views/product_views.xml +++ b/addons/stock/views/product_views.xml @@ -54,8 +54,9 @@ - - + + + @@ -157,9 +158,10 @@ + -
On hand:
+
On hand: