diff --git a/mrp_operations_extension/models/mrp_bom.py b/mrp_operations_extension/models/mrp_bom.py index 4504e9435..3bbf11508 100644 --- a/mrp_operations_extension/models/mrp_bom.py +++ b/mrp_operations_extension/models/mrp_bom.py @@ -43,7 +43,7 @@ class MrpBom(models.Model): seq = work_order['sequence'] - level routing_lines = routing_line_obj.search([ ('routing_id', '=', routing_id), ('sequence', '=', seq)]) - routing_line_id = routing_lines.id + 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 diff --git a/mrp_operations_extension/models/mrp_routing.py b/mrp_operations_extension/models/mrp_routing.py index 474ac7d02..56c87ee94 100644 --- a/mrp_operations_extension/models/mrp_routing.py +++ b/mrp_operations_extension/models/mrp_routing.py @@ -84,8 +84,9 @@ class MrpRoutingWorkcenter(models.Model): 'op_number': self.operation.op_number, } op_wc_lst.append(data) - op_wc_lst[0]['default'] = True - self.op_wc_lines = op_wc_lst + if op_wc_lst: + op_wc_lst[0]['default'] = True + self.op_wc_lines = op_wc_lst @api.one @api.onchange('op_wc_lines')