修改排程逻辑

This commit is contained in:
胡尧
2024-10-28 09:38:50 +08:00
parent 3f84972bfd
commit aa1353cf99

View File

@@ -246,26 +246,26 @@ class sf_production_plan(models.Model):
record.date_planned_finished = item.date_planned_finished record.date_planned_finished = item.date_planned_finished
# 计算下一个cnc工单的开始时间 # 计算下一个cnc工单的开始时间
last_cnc_start = workorder_list[-1].date_planned_finished + timedelta(minutes=pre_duration) last_cnc_start = workorder_list[-1].date_planned_finished + timedelta(minutes=pre_duration)
record.state = 'done' record.state = 'done'
# record.production_id.schedule_state = '已排' # record.production_id.schedule_state = '已排'
record.sudo().production_id.schedule_state = '已排' record.sudo().production_id.schedule_state = '已排'
record.sudo().production_id.process_state = '待装夹' record.sudo().production_id.process_state = '待装夹'
# self.env['sale.order'].browse(record.production_id.origin).schedule_status = 'to process' # self.env['sale.order'].browse(record.production_id.origin).schedule_status = 'to process'
# sale_obj = self.env['sale.order'].search([('name', '=', record.origin)]) # sale_obj = self.env['sale.order'].search([('name', '=', record.origin)])
# if 'S' in sale_obj.name: # if 'S' in sale_obj.name:
# sale_obj.schedule_status = 'to process' # sale_obj.schedule_status = 'to process'
mrp_production_ids = record.production_id._get_children().ids mrp_production_ids = record.production_id._get_children().ids
print('mrp_production_ids', mrp_production_ids) print('mrp_production_ids', mrp_production_ids)
for i in mrp_production_ids: for i in mrp_production_ids:
record.env['mrp.production'].sudo().browse(i).schedule_state = '已排' record.env['mrp.production'].sudo().browse(i).schedule_state = '已排'
# record.production_id.date_planned_start = record.date_planned_start # record.production_id.date_planned_start = record.date_planned_start
# record.production_id.date_planned_finished = record.date_planned_finished # record.production_id.date_planned_finished = record.date_planned_finished
record.sudo().production_id.production_line_id = record.production_line_id.id record.sudo().production_id.production_line_id = record.production_line_id.id
if record.production_id.workorder_ids: if record.production_id.workorder_ids:
record.sudo().production_id.workorder_ids.filtered( record.sudo().production_id.workorder_ids.filtered(
lambda b: b.routing_type == "装夹预调").workpiece_delivery_ids.write( lambda b: b.routing_type == "装夹预调").workpiece_delivery_ids.write(
{'production_line_id': record.production_line_id.id, {'production_line_id': record.production_line_id.id,
'plan_start_processing_time': record.date_planned_start}) 'plan_start_processing_time': record.date_planned_start})
# record.date_planned_finished = record.date_planned_start + timedelta(days=3) # record.date_planned_finished = record.date_planned_start + timedelta(days=3)
# record.state = 'done' # record.state = 'done'