[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) <whe@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -54,8 +54,9 @@
|
||||
<field name="inherit_id" ref="product.product_template_tree_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="uom_id" position="before">
|
||||
<field name="qty_available" attrs="{'invisible':[('type', '!=', 'product')]}" optional="show" decoration-danger="qty_available < 0"/>
|
||||
<field name="virtual_available" attrs="{'invisible':[('type', '!=', 'product')]}" optional="show" decoration-danger="virtual_available < 0" decoration-bf="1"/>
|
||||
<field name="show_on_hand_qty_status_button" invisible="1"/>
|
||||
<field name="qty_available" attrs="{'invisible':[('show_on_hand_qty_status_button', '=', False)]}" optional="show" decoration-danger="qty_available < 0"/>
|
||||
<field name="virtual_available" attrs="{'invisible':[('show_on_hand_qty_status_button', '=', False)]}" optional="show" decoration-danger="virtual_available < 0" decoration-bf="1"/>
|
||||
</field>
|
||||
<field name="default_code" position="after">
|
||||
<field name="responsible_id" widget="many2one_avatar_user"/>
|
||||
@@ -157,9 +158,10 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//kanban" position="inside">
|
||||
<field name="type"/>
|
||||
<field name="show_on_hand_qty_status_button"/>
|
||||
</xpath>
|
||||
<xpath expr="//div[@name='product_lst_price']" position="after">
|
||||
<div t-if="record.type.raw_value == 'product'">On hand: <field name="qty_available"/> <field name="uom_id"/></div>
|
||||
<div t-if="record.show_on_hand_qty_status_button.raw_value">On hand: <field name="qty_available"/> <field name="uom_id"/></div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user