From 38ac9ccbc1921e4860de4885e8a79b1303632095 Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Wed, 9 Dec 2020 09:45:43 +0000 Subject: [PATCH] [IMP] mrp: operations listview On the MRP operation model (`mrp.routing.workcenter`): - Changes the order (ordered by workcenter and BOM in priority); - Adds computed field, `time_computed_on`, which is only used in list view (display on how many numbers of work orders the duration is computed); - Adds multiple fields in list view (often optional display); - Adds two groupby (by BOM and by workcenter). task-2382256 --- addons/mrp/models/mrp_routing.py | 8 +++++- addons/mrp/views/mrp_bom_views.xml | 2 +- addons/mrp/views/mrp_routing_views.xml | 36 ++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/addons/mrp/models/mrp_routing.py b/addons/mrp/models/mrp_routing.py index 58192f87f82..aab87600062 100644 --- a/addons/mrp/models/mrp_routing.py +++ b/addons/mrp/models/mrp_routing.py @@ -7,7 +7,7 @@ from odoo import api, fields, models, _ class MrpRoutingWorkcenter(models.Model): _name = 'mrp.routing.workcenter' _description = 'Work Center Usage' - _order = 'sequence, id' + _order = 'bom_id, sequence, id' _check_company_auto = True name = fields.Char('Operation', required=True) @@ -33,6 +33,7 @@ class MrpRoutingWorkcenter(models.Model): ('manual', 'Set duration manually')], string='Duration Computation', default='manual') time_mode_batch = fields.Integer('Based on', default=10) + time_computed_on = fields.Char('Computed on last', compute='_compute_time_computed_on') time_cycle_manual = fields.Float( 'Manual Duration', default=60, help="Time in minutes:" @@ -42,6 +43,11 @@ class MrpRoutingWorkcenter(models.Model): workorder_count = fields.Integer("# Work Orders", compute="_compute_workorder_count") workorder_ids = fields.One2many('mrp.workorder', 'operation_id', string="Work Orders") + @api.depends('time_mode', 'time_mode_batch') + def _compute_time_computed_on(self): + for operation in self: + operation.time_computed_on = _('%i work orders') % operation.time_mode_batch if operation.time_mode != 'manual' else False + @api.depends('time_cycle_manual', 'time_mode', 'workorder_ids') def _compute_time_cycle(self): manual_ops = self.filtered(lambda operation: operation.time_mode == 'manual') diff --git a/addons/mrp/views/mrp_bom_views.xml b/addons/mrp/views/mrp_bom_views.xml index 6e7b5384f5a..227dcaf8817 100644 --- a/addons/mrp/views/mrp_bom_views.xml +++ b/addons/mrp/views/mrp_bom_views.xml @@ -103,7 +103,7 @@ + context="{'bom_id_invisible': True, 'default_company_id': company_id, 'default_bom_id': id, 'tree_view_ref': 'mrp.mrp_routing_workcenter_bom_tree_view'}"/> mrp.routing.workcenter.tree mrp.routing.workcenter - - + + + + + + + mrp.routing.workcenter.bom.tree + mrp.routing.workcenter + + 1000 + primary + + + + + + + + mrp.routing.workcenter.form mrp.routing.workcenter @@ -75,6 +92,21 @@ + + mrp.routing.workcenter.filter + mrp.routing.workcenter + + + + + + + + + + + +