[FIX] mrp: allow adding components to done mo when uom active

Steps to reproduce:
1. Activiate "Units of Measure" setting
2. Create and "mark as done" a MO
3. Unlock MO (may need to activate MRP setting for locking/unlocking qty
   to consume to see button to unlock first)
4. Add a new component to MO and save.

Expected result: New component added
Actual result: Validation Error related to UoM

This is due to all components' UoM being readonly once the MO is Done so
when the new component move is created, it is missing a UoM value.

We fix this by making any newly added component lines' UoM not readonly
regardless of MO status. When a user saves a MO after adding a new
component, they will not be able to edit the UoM again due to
quant/stock move inconsistencies this can cause.

closes odoo/odoo#75436

Opw: 2514262
X-original-commit: ab0fcdbceef3e2df7b89766b074c386465c60ad7
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
Tiffany Chang (tic)
2021-08-30 21:05:19 +00:00
parent 3dea610ac1
commit 2cb659aa7c
+1 -1
View File
@@ -283,7 +283,7 @@
<field name="state" invisible="1" force_save="1"/>
<field name="should_consume_qty" invisible="1"/>
<field name="product_uom_qty" widget="mrp_should_consume" string="To Consume" attrs="{'readonly': ['&amp;', ('parent.state', '!=', 'draft'), '|', '&amp;', ('parent.state', 'not in', ('confirmed', 'progress', 'to_close')), ('parent.is_planned', '!=', True), ('parent.is_locked', '=', True)]}" width="1"/>
<field name="product_uom" attrs="{'readonly': [('state', '!=', 'draft')]}" options="{'no_open': True, 'no_create': True}" groups="uom.group_uom"/>
<field name="product_uom" attrs="{'readonly': [('state', '!=', 'draft'), ('id', '!=', False)]}" options="{'no_open': True, 'no_create': True}" groups="uom.group_uom"/>
<field name="product_type" invisible="1"/>
<field name="product_qty" invisible="1" readonly="1"/>
<field name="reserved_availability" invisible="1"/>