解除装夹起点从下产线agv调度任务关联带出

This commit is contained in:
胡尧
2024-09-06 15:34:30 +08:00
parent 096542c8ff
commit 2d5ef0aae4
3 changed files with 29 additions and 2 deletions

View File

@@ -265,3 +265,17 @@ class ResMrpWorkOrder(models.Model):
'sf_agv_scheduling_mrp_workorder_ref', 'sf_agv_scheduling_mrp_workorder_ref',
string='AGV调度', string='AGV调度',
domain=[('state', '!=', '已取消')]) domain=[('state', '!=', '已取消')])
def get_down_product_agv_scheduling(self):
"""
获取关联的制造订单下产线的agv任务
"""
workorder_ids = self.production_id.workorder_ids
cnc_workorder = workorder_ids.filtered(
lambda w: w.routing_type == 'CNC加工' and w.state == 'done' and w.processing_panel == self.processing_panel
)
if cnc_workorder:
agv_schedulingss = cnc_workorder.agv_scheduling_ids
return agv_schedulingss.filtered(lambda a: a.state == '已配送' and a.agv_route_type == '下产线')
else:
return None

View File

@@ -1340,7 +1340,7 @@ class ResMrpWorkOrder(models.Model):
'name': 'button_delivery', 'name': 'button_delivery',
'type': 'object', 'type': 'object',
'string': '解除装夹', 'string': '解除装夹',
'class': 'btn-primary', 'class': 'btn-primary jikimo_button_confirm',
# 'className': 'btn-primary', # 'className': 'btn-primary',
'modifiers': '{"force_show": 1}' 'modifiers': '{"force_show": 1}'
}) })
@@ -1355,6 +1355,7 @@ class ResMrpWorkOrder(models.Model):
workorder_ids = [] workorder_ids = []
delivery_type = '运送空料架' delivery_type = '运送空料架'
max_num = 4 # 最大配送数量 max_num = 4 # 最大配送数量
feeder_station_start_id = False
if len(self) > max_num: if len(self) > max_num:
raise UserError('仅限于拆卸1-4个制造订单请重新选择') raise UserError('仅限于拆卸1-4个制造订单请重新选择')
for item in self: for item in self:
@@ -1363,6 +1364,10 @@ class ResMrpWorkOrder(models.Model):
production_ids.append(item.production_id.id) production_ids.append(item.production_id.id)
workorder_ids.append(item.id) workorder_ids.append(item.id)
if not feeder_station_start_id:
down_product_agv_scheduling = self.get_down_product_agv_scheduling()
if down_product_agv_scheduling:
feeder_station_start_id = down_product_agv_scheduling.end_site_id.id
return { return {
'name': _('确认'), 'name': _('确认'),
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
@@ -1375,7 +1380,8 @@ class ResMrpWorkOrder(models.Model):
'default_delivery_type': delivery_type, 'default_delivery_type': delivery_type,
'default_workorder_ids': [(6, 0, workorder_ids)], 'default_workorder_ids': [(6, 0, workorder_ids)],
'default_workcenter_id': self.env.context.get('default_workcenter_id'), 'default_workcenter_id': self.env.context.get('default_workcenter_id'),
'default_confirm_button': '确认解除' 'default_confirm_button': '确认解除',
'default_feeder_station_start_id': feeder_station_start_id,
}} }}

View File

@@ -210,6 +210,13 @@ class WorkpieceDeliveryWizard(models.TransientModel):
# 将对象添加到对应的同模型且是多对多类型里 # 将对象添加到对应的同模型且是多对多类型里
self.production_ids |= workorder.production_id self.production_ids |= workorder.production_id
self.workorder_ids |= workorder self.workorder_ids |= workorder
if not self.feeder_station_start_id:
down_product_agv_scheduling = self.get_down_product_agv_scheduling()
if down_product_agv_scheduling:
self.feeder_station_start_id = down_product_agv_scheduling.end_site_id.id
else: else:
raise UserError('该rfid码对应的工单不存在') raise UserError('该rfid码对应的工单不存在')
return return