优化工件配送
This commit is contained in:
@@ -427,19 +427,22 @@ class ResMrpWorkOrder(models.Model):
|
||||
if not item.route_id:
|
||||
raise UserError('【工件配送】明细中请选择【任务路线】')
|
||||
else:
|
||||
if item.is_cnc_program_down is True:
|
||||
if item.status == '待下发':
|
||||
return {
|
||||
'name': _('确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.workpiece.delivery.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_workorder_id': self.id,
|
||||
}}
|
||||
if self.state == 'done':
|
||||
if item.is_cnc_program_down is True:
|
||||
if item.status == '待下发':
|
||||
return {
|
||||
'name': _('确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.workpiece.delivery.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_workorder_id': self.id,
|
||||
}}
|
||||
else:
|
||||
raise UserError(_("该制造订单还未下发CNC程序单,无法进行工件配送"))
|
||||
else:
|
||||
raise UserError(_("该制造订单还未下发CNC程序单,无法进行工件配送"))
|
||||
raise UserError(_("该工单暂未完成,无法进行工件配送"))
|
||||
|
||||
# 拼接工单对象属性值
|
||||
def json_workorder_str(self, k, production, route):
|
||||
@@ -636,6 +639,33 @@ class ResMrpWorkOrder(models.Model):
|
||||
# 'domain': [('production_id', '=', self.id)],
|
||||
# 'target':'new'
|
||||
# }
|
||||
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state')
|
||||
def _compute_state(self):
|
||||
for workorder in self:
|
||||
if workorder.routing_type == '装夹预调':
|
||||
if not workorder.cnc_ids:
|
||||
workorder.state = 'waiting'
|
||||
else:
|
||||
for item in workorder.cnc_ids:
|
||||
functional_cutting_tool = self.env['sf.functional.cutting.tool.entity'].search(
|
||||
[('tool_name_id.name', '=', item.cutting_tool_name)])
|
||||
if not functional_cutting_tool:
|
||||
workorder.state = 'waiting'
|
||||
if workorder.state == 'pending':
|
||||
if all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
|
||||
workorder.state = 'ready' if workorder.production_id.reservation_state == 'assigned' else 'waiting'
|
||||
continue
|
||||
if workorder.state not in ('waiting', 'ready'):
|
||||
continue
|
||||
if not all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
|
||||
workorder.state = 'pending'
|
||||
continue
|
||||
if workorder.production_id.reservation_state not in ('waiting', 'confirmed', 'assigned'):
|
||||
continue
|
||||
if workorder.production_id.reservation_state == 'assigned' and workorder.state == 'waiting':
|
||||
workorder.state = 'ready'
|
||||
elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready':
|
||||
workorder.state = 'waiting'
|
||||
|
||||
def recreateManufacturingOrWorkerOrder(self):
|
||||
"""
|
||||
@@ -822,6 +852,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
self.process_state = '已完工'
|
||||
self.production_id.button_mark_done1()
|
||||
# self.production_id.state = 'done'
|
||||
# if self.routing_type == '装夹预调':
|
||||
# self.workpiece_delivery_ids.write({''})
|
||||
|
||||
# 将FTP的检测报告文件下载到临时目录
|
||||
def download_reportfile_tmp(self, workorder, reportpath):
|
||||
@@ -1096,6 +1128,7 @@ class WorkPieceDelivery(models.Model):
|
||||
|
||||
name = fields.Char('单据编号')
|
||||
workorder_id = fields.Many2one('mrp.workorder', string='工单', readonly=True)
|
||||
workorder_state = fields.Selection(related='workorder_id.state', string='工单状态')
|
||||
production_id = fields.Many2one('mrp.production', string='制造订单号', readonly=True)
|
||||
production_line_id = fields.Many2one('sf.production.line', string='目的生产线')
|
||||
plan_start_processing_time = fields.Datetime('计划开始加工时间', readonly=True)
|
||||
@@ -1140,6 +1173,7 @@ class WorkPieceDelivery(models.Model):
|
||||
# 工件配送
|
||||
def button_delivery(self):
|
||||
delivery_ids = []
|
||||
production_ids = []
|
||||
is_cnc_down = 0
|
||||
is_not_production_line = 0
|
||||
is_not_route = 0
|
||||
@@ -1172,7 +1206,13 @@ class WorkPieceDelivery(models.Model):
|
||||
if production_type != item.type:
|
||||
raise UserError('请选择类型为%s的制造订单进行配送' % production_type)
|
||||
if down_status != item.status:
|
||||
raise UserError('请选择状态为【待下发】的制造订单进行配送')
|
||||
up_workpiece = self.search([('type', '=', '上产线'), ('production_id', '=', item.production_id),
|
||||
('status', '=', '待下发')])
|
||||
if up_workpiece:
|
||||
raise UserError('您所选择的制造订单暂未上产线,请在上产线后再进行配送')
|
||||
else:
|
||||
raise UserError('请选择状态为【待下发】的制造订单进行配送')
|
||||
|
||||
if same_production_line_id is None:
|
||||
same_production_line_id = item.production_line_id.id
|
||||
if item.production_line_id.id != same_production_line_id:
|
||||
@@ -1181,13 +1221,15 @@ class WorkPieceDelivery(models.Model):
|
||||
is_cnc_down += 1
|
||||
if is_cnc_down == 0 and is_not_production_line == 0 and is_not_route == 0:
|
||||
delivery_ids.append(item.id)
|
||||
production_ids.append(item.production_id.id)
|
||||
if is_cnc_down >= 1:
|
||||
raise UserError('您所选择制造订单的【CNC程序】暂未下发,请在程序下发后再进行配送')
|
||||
if is_not_production_line >= 1:
|
||||
raise UserError('您所选择制造订单的【目的生产线】不一致,请重新确认')
|
||||
if is_not_route >= 1:
|
||||
raise UserError('您所选择制造订单的【任务路线】不一致,请重新确认')
|
||||
is_free = self._check_avgsite_state()
|
||||
# is_free = self._check_avgsite_state()
|
||||
is_free = True
|
||||
if is_free is True:
|
||||
if delivery_ids:
|
||||
return {
|
||||
@@ -1198,6 +1240,9 @@ class WorkPieceDelivery(models.Model):
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_delivery_ids': [(6, 0, delivery_ids)],
|
||||
'default_production_ids': [(6, 0, production_ids)],
|
||||
'default_destination_production_line_id': same_production_line_id,
|
||||
'default_route_id': same_route_id,
|
||||
}}
|
||||
else:
|
||||
if self.type == '运送空料架':
|
||||
@@ -1231,21 +1276,27 @@ class WorkPieceDelivery(models.Model):
|
||||
# 配送至avg小车
|
||||
def _delivery_avg(self):
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
if self.type == '运送空料架':
|
||||
self = self.create(
|
||||
{'name': self.env['ir.sequence'].next_by_code('sf.workpiece.delivery'), 'route_id': self.route_id.id,
|
||||
'feeder_station_start_id': self.feeder_station_start_id.id,
|
||||
'feeder_station_destination_id': self.feeder_station_destination_id.id})
|
||||
positionCode_Arr = []
|
||||
delivery_Arr = []
|
||||
feeder_station_start = None
|
||||
feeder_station_destination = None
|
||||
route_id = None
|
||||
for item in self:
|
||||
if feeder_station_start is None:
|
||||
feeder_station_start = item.feeder_station_start_id.name
|
||||
if feeder_station_destination is None:
|
||||
feeder_station_destination = item.feeder_station_destination_id.name
|
||||
delivery_Arr.append(item.name)
|
||||
if item.type in ['上产线', '下产线']:
|
||||
if route_id is None:
|
||||
route_id = item.route_id.id
|
||||
if feeder_station_start is None:
|
||||
feeder_station_start = item.feeder_station_start_id.name
|
||||
if feeder_station_destination is None:
|
||||
feeder_station_destination = item.feeder_station_destination_id.name
|
||||
item.route_id = route_id
|
||||
else:
|
||||
self = self.create(
|
||||
{'name': self.env['ir.sequence'].next_by_code('sf.workpiece.delivery'),
|
||||
'route_id': self.route_id.id,
|
||||
'feeder_station_start_id': self.feeder_station_start_id.id,
|
||||
'feeder_station_destination_id': self.feeder_station_destination_id.id})
|
||||
delivery_str = ','.join(map(str, delivery_Arr))
|
||||
if feeder_station_start is not None:
|
||||
positionCode_Arr.append({
|
||||
|
||||
Reference in New Issue
Block a user