[IMP] mrp: Improve UI of Manual Consumption field on BOM

Auto mark manual_consumption as True as soon as the component is use in
an operation and make the field read-only

task-2925474

Part-of: odoo/odoo#97588
This commit is contained in:
Triet Ngo
2022-09-02 14:17:58 +02:00
parent dae82e7aae
commit e2d4586ac7
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -409,9 +409,9 @@ class MrpBomLine(models.Model):
'You should install the mrp_byproduct module if you want to manage extra products on BoMs !'),
]
@api.depends('product_id', 'tracking')
@api.depends('product_id', 'tracking', 'operation_id')
def _compute_manual_consumption(self):
self.filtered(lambda m: m.tracking != 'none').manual_consumption = True
self.filtered(lambda m: m.tracking != 'none' or m.operation_id).manual_consumption = True
@api.depends('product_id', 'bom_id')
def _compute_child_bom_id(self):
+1 -1
View File
@@ -99,7 +99,7 @@
<field name="allowed_operation_ids" invisible="1"/>
<field name="operation_id" groups="mrp.group_mrp_routings" optional="hidden" attrs="{'column_invisible': [('parent.type','not in', ('normal', 'phantom'))]}" options="{'no_quick_create':True,'no_create_edit':True}"/>
<field name="tracking" invisible="1"/>
<field name="manual_consumption" optional="hide" width="1.0" attrs="{'readonly': [('tracking', '!=', 'none')]}"/>
<field name="manual_consumption" groups="mrp.group_mrp_routings" optional="hide" width="1.0" attrs="{'readonly': ['|', ('tracking', '!=', 'none'), ('operation_id', '!=', False)]}"/>
</tree>
</field>
</page>