From a191e8cad8ae933438bfd58c4a10cfd23947bd54 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Fri, 17 Apr 2015 02:20:23 +0200 Subject: [PATCH] [FIX] mrp_operations_extension: Added hr dependency. Closes #753. Retrieve correctly work center --- mrp_operations_extension/__openerp__.py | 1 + mrp_operations_extension/models/mrp_bom.py | 27 +++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/mrp_operations_extension/__openerp__.py b/mrp_operations_extension/__openerp__.py index 7258caa19..2534b558b 100644 --- a/mrp_operations_extension/__openerp__.py +++ b/mrp_operations_extension/__openerp__.py @@ -36,6 +36,7 @@ "mrp_operations", "mrp", "stock", + "hr", ], "data": [ "wizard/mrp_workorder_produce_view.xml", diff --git a/mrp_operations_extension/models/mrp_bom.py b/mrp_operations_extension/models/mrp_bom.py index 3bbf11508..0125c0c4c 100644 --- a/mrp_operations_extension/models/mrp_bom.py +++ b/mrp_operations_extension/models/mrp_bom.py @@ -40,25 +40,30 @@ class MrpBom(models.Model): routing_id=False): routing_line_obj = self.env['mrp.routing.workcenter'] for work_order in result2: + if (work_order['sequence'] < level or + work_order.get('routing_wc_line')): + continue seq = work_order['sequence'] - level - routing_lines = routing_line_obj.search([ - ('routing_id', '=', routing_id), ('sequence', '=', seq)]) - routing_line_id = routing_lines and routing_lines[0].id or False - for routing_line in routing_lines: - if routing_line.name in work_order['name']: - routing_line_id = routing_line.id + domain = [('routing_id', '=', routing_id), + ('sequence', '=', seq), + ('workcenter_id', '=', work_order['workcenter_id'])] + routing_lines = routing_line_obj.search(domain) + routing_line = (routing_lines and routing_lines[0] or + routing_line_obj) + for rl in routing_lines: + if rl.name in work_order['name']: + routing_line = rl break - wc = routing_line_obj.browse(routing_line_id) - cycle = int(math.ceil(factor / wc.cycle_nbr)) + wc = routing_line + cycle = wc.cycle_nbr and int(math.ceil(factor / wc.cycle_nbr)) or 0 hour = wc.hour_nbr * cycle default_wc_line = wc.op_wc_lines.filtered(lambda r: r.default) work_order['cycle'] = cycle work_order['hour'] = hour work_order['time_start'] = default_wc_line.time_start or 0.0 work_order['time_stop'] = default_wc_line.time_stop or 0.0 - if 'routing_wc_line' not in work_order: - work_order['routing_wc_line'] = routing_line_id - work_order['do_production'] = wc.do_production + work_order['routing_wc_line'] = routing_line.id + work_order['do_production'] = wc.do_production return result2 @api.multi