[REF] mrp: consumption of workorder become related

Avoid duplicate information in DB.

task-2373638
This commit is contained in:
Rémy Voet (ryv)
2021-01-05 08:32:58 +00:00
parent 4d57ce473b
commit e292c3fb53
3 changed files with 2 additions and 8 deletions
-1
View File
@@ -798,7 +798,6 @@ class MrpProduction(models.Model):
'product_uom_id': production.product_uom_id.id,
'operation_id': operation.id,
'state': 'pending',
'consumption': production.consumption,
}]
production.workorder_ids = [(5, 0)] + [(0, 0, value) for value in workorders_values]
for workorder in production.workorder_ids:
+1 -6
View File
@@ -140,12 +140,7 @@ class MrpWorkorder(models.Model):
production_date = fields.Datetime('Production Date', related='production_id.date_planned_start', store=True, readonly=False)
json_popover = fields.Char('Popover Data JSON', compute='_compute_json_popover')
show_json_popover = fields.Boolean('Show Popover?', compute='_compute_json_popover')
consumption = fields.Selection([
('strict', 'Strict'),
('warning', 'Warning'),
('flexible', 'Flexible')],
required=True,
)
consumption = fields.Selection(related='production_id.consumption')
@api.depends('production_state', 'date_planned_start', 'date_planned_finished')
def _compute_json_popover(self):
+1 -1
View File
@@ -282,7 +282,7 @@
</field>
</page>
<page string="Work Orders" name="operations" groups="mrp.group_mrp_routings">
<field name="workorder_ids" attrs="{'readonly': [('state', 'in', ['cancel', 'done'])]}" context="{'tree_view_ref': 'mrp.mrp_production_workorder_tree_editable_view', 'form_view_ref': 'mrp.mrp_production_workorder_form_view_inherit', 'default_product_uom_id': product_uom_id, 'default_consumption': consumption, 'default_company_id': company_id}"/>
<field name="workorder_ids" attrs="{'readonly': [('state', 'in', ['cancel', 'done'])]}" context="{'tree_view_ref': 'mrp.mrp_production_workorder_tree_editable_view', 'form_view_ref': 'mrp.mrp_production_workorder_form_view_inherit', 'default_product_uom_id': product_uom_id}"/>
</page>
<page string="By-Products" name="finished_products" groups="mrp.group_mrp_byproducts">
<field name="move_byproduct_ids" context="{'default_date': date_planned_finished, 'default_date_deadline': date_deadline, 'default_location_id': production_location_id, 'default_location_dest_id': location_src_id, 'default_state': 'draft', 'default_production_id': id, 'default_picking_type_id': picking_type_id, 'default_company_id': company_id}" attrs="{'readonly': ['|', ('state', '=', 'cancel'), '&amp;', ('state', '=', 'done'), ('is_locked', '=', True)]}" options="{'delete': [('state', '=', 'draft')]}">