[FIX] mrp: show manual consumption when workorder not enabled
In 49bc9aac201136e684cac9d84df97f80d217afa4, when we need operation_id when we check if manual_consumption is readonly or not, so groups="mrp.group_mrp_routings" was added for manual_consumption. As a result, we can't see manual_consumption on BOM when workorder is not enabled. To fix, we add a computed field as a workaround. Task-3116125 Part-of: odoo/odoo#113538
This commit is contained in:
@@ -407,6 +407,8 @@ class MrpBomLine(models.Model):
|
||||
'Manual Consumption', default=False, compute='_compute_manual_consumption', store=True, copy=True,
|
||||
help="When activated, then the registration of consumption for that component is recorded manually exclusively.\n"
|
||||
"If not activated, and any of the components consumption is edited manually on the manufacturing order, Odoo assumes manual consumption also.")
|
||||
manual_consumption_readonly = fields.Boolean(
|
||||
'Manual Consumption Readonly', compute='_compute_manual_consumption_readonly')
|
||||
|
||||
_sql_constraints = [
|
||||
('bom_qty_zero', 'CHECK (product_qty>=0)', 'All product quantities must be greater or equal to 0.\n'
|
||||
@@ -418,6 +420,11 @@ class MrpBomLine(models.Model):
|
||||
def _compute_manual_consumption(self):
|
||||
self.filtered(lambda m: m.tracking != 'none' or m.operation_id).manual_consumption = True
|
||||
|
||||
@api.depends('tracking', 'operation_id')
|
||||
def _compute_manual_consumption_readonly(self):
|
||||
for line in self:
|
||||
line.manual_consumption_readonly = (line.tracking != 'none' or line.operation_id)
|
||||
|
||||
@api.depends('product_id', 'bom_id')
|
||||
def _compute_child_bom_id(self):
|
||||
products = self.product_id
|
||||
|
||||
@@ -98,8 +98,8 @@
|
||||
<field name="bom_product_template_attribute_value_ids" optional="hide" widget="many2many_tags" options="{'no_create': True}" attrs="{'column_invisible': [('parent.product_id', '!=', False)]}" groups="product.group_product_variant"/>
|
||||
<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" groups="mrp.group_mrp_routings" optional="hide" attrs="{'readonly': ['|', ('tracking', '!=', 'none'), ('operation_id', '!=', False)]}"/>
|
||||
<field name="manual_consumption_readonly" invisible="1"/>
|
||||
<field name="manual_consumption" optional="hide" attrs="{'readonly': [('manual_consumption_readonly', '=', True)]}"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
|
||||
Reference in New Issue
Block a user