修复bug和优化制造订单报废

This commit is contained in:
jinling.yang
2024-11-20 16:08:27 +08:00
parent e634e9726f
commit 23da273af1
6 changed files with 50 additions and 85 deletions

View File

@@ -782,7 +782,7 @@ class ResMrpWorkOrder(models.Model):
routing_types = ['切割', '装夹预调', 'CNC加工', '解除装夹']
if route.route_id.routing_type in routing_types:
routing_workcenter = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', route.route_id.routing_type)])
[('name', '=', oute.routing_type if hasattr(route, 'routing_type') else route.route_id.routing_type)])
duration_expected = routing_workcenter.time_cycle
reserved_duration = routing_workcenter.reserved_duration
else:
@@ -792,14 +792,15 @@ class ResMrpWorkOrder(models.Model):
'product_uom_id': production.product_uom_id.id,
'qty_producing': 0,
'operation_id': False,
'name': route.route_id.name,
'processing_panel': route.panel,
'sequence': route.sequence,
'quality_point_ids': route.route_id.quality_point_ids,
'routing_type': route.route_id.routing_type,
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.route_id.workcenter_ids.ids,
route.route_id.routing_type,
production.product_id),
'name': route.name if hasattr(route, 'routing_type') else route.route_id.name,
'processing_panel': False if hasattr(route, 'routing_type') else route.panel,
'sequence': 1 if hasattr(route, 'routing_type') else route.sequence,
'quality_point_ids': False if hasattr(route, 'routing_type') else route.route_id.quality_point_ids,
'routing_type': route.routing_type if hasattr(route, 'routing_type') else route.route_id.routing_type,
'workcenter_id': False if hasattr(route, 'routing_type') else self.env[
'mrp.routing.workcenter'].get_workcenter(route.route_id.workcenter_ids.ids,
route.route_id.routing_type,
production.product_id),
# 设定初始化值避免出现变成bool问题
'date_planned_start': datetime.now(),
'date_planned_finished': datetime.now() + timedelta(days=1),