修改排程单的问题
This commit is contained in:
@@ -1378,7 +1378,8 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
# workorder.rfid_code_old = rfid_code
|
# workorder.rfid_code_old = rfid_code
|
||||||
# workorder.rfid_code = False
|
# workorder.rfid_code = False
|
||||||
logging.info('workorder.rfid_code:%s' % workorder.rfid_code)
|
logging.info('workorder.rfid_code:%s' % workorder.rfid_code)
|
||||||
if is_production_id is True and record.routing_type in ['解除装夹', '表面工艺', '切割']:
|
# if is_production_id is True and record.routing_type in ['解除装夹', '表面工艺', '切割']:
|
||||||
|
if is_production_id is True:
|
||||||
logging.info('product_qty:%s' % record.production_id.product_qty)
|
logging.info('product_qty:%s' % record.production_id.product_qty)
|
||||||
for move_raw_id in record.production_id.move_raw_ids:
|
for move_raw_id in record.production_id.move_raw_ids:
|
||||||
move_raw_id.quantity_done = move_raw_id.product_uom_qty
|
move_raw_id.quantity_done = move_raw_id.product_uom_qty
|
||||||
|
|||||||
@@ -231,26 +231,42 @@ class sf_production_plan(models.Model):
|
|||||||
if not record.production_line_id:
|
if not record.production_line_id:
|
||||||
raise ValidationError("未选择生产线")
|
raise ValidationError("未选择生产线")
|
||||||
else:
|
else:
|
||||||
if record.production_id.workorder_ids:
|
# 自动化产线加工
|
||||||
last_cnc_start = record.date_planned_start if record.date_planned_start else datetime.now()
|
if record.production_id.production_type == '自动化产线加工':
|
||||||
for item in record.production_id.workorder_ids:
|
if record.production_id.workorder_ids:
|
||||||
if item.name == 'CNC加工':
|
last_cnc_start = record.date_planned_start if record.date_planned_start else datetime.now()
|
||||||
# 将同一个面的所有工单筛选出来
|
for item in record.production_id.workorder_ids:
|
||||||
workorder_list = record.production_id.workorder_ids.filtered(lambda x: x.processing_panel == item.processing_panel)
|
if item.name == 'CNC加工':
|
||||||
routing_workcenter = record.env['mrp.routing.workcenter'].sudo().search(
|
# 将同一个面的所有工单筛选出来
|
||||||
[('name', '=', 'CNC加工')], limit=1)
|
workorder_list = record.production_id.workorder_ids.filtered(lambda x: x.processing_panel == item.processing_panel)
|
||||||
# 设置一个小的开始时间
|
routing_workcenter = record.env['mrp.routing.workcenter'].sudo().search(
|
||||||
item.date_planned_start = datetime.now() - timedelta(days=100)
|
[('name', '=', 'CNC加工')], limit=1)
|
||||||
item.date_planned_finished = last_cnc_start + timedelta(
|
# 设置一个小的开始时间
|
||||||
minutes=routing_workcenter.time_cycle)
|
item.date_planned_start = datetime.now() - timedelta(days=100)
|
||||||
item.date_planned_start = last_cnc_start
|
item.date_planned_finished = last_cnc_start + timedelta(
|
||||||
record.sudo().production_id.plan_start_processing_time = item.date_planned_start
|
minutes=routing_workcenter.time_cycle)
|
||||||
item.duration_expected = routing_workcenter.time_cycle
|
item.date_planned_start = last_cnc_start
|
||||||
pre_duration , next_duration = record.calculate_plan_time(item, workorder_list)
|
record.sudo().production_id.plan_start_processing_time = item.date_planned_start
|
||||||
record.date_planned_finished = item.date_planned_finished
|
item.duration_expected = routing_workcenter.time_cycle
|
||||||
# 计算下一个cnc工单的开始时间
|
pre_duration , next_duration = record.calculate_plan_time(item, workorder_list)
|
||||||
last_cnc_start = workorder_list[-1].date_planned_finished + timedelta(minutes=pre_duration)
|
record.date_planned_finished = item.date_planned_finished
|
||||||
# 没有工单也能排程
|
# 计算下一个cnc工单的开始时间
|
||||||
|
last_cnc_start = workorder_list[-1].date_planned_finished + timedelta(minutes=pre_duration)
|
||||||
|
# 没有工单也能排程
|
||||||
|
else:
|
||||||
|
# 人工线下加工只排第一张工单
|
||||||
|
if record.production_id.workorder_ids:
|
||||||
|
item = record.production_id.workorder_ids[0]
|
||||||
|
last_wo_start = record.date_planned_start if record.date_planned_start else datetime.now()
|
||||||
|
routing_workcenter = record.env['mrp.routing.workcenter'].sudo().search(
|
||||||
|
[('name', '=', item.routing_type)], limit=1)
|
||||||
|
item.date_planned_start = datetime.now() - timedelta(days=100)
|
||||||
|
item.date_planned_finished = last_wo_start + timedelta(
|
||||||
|
minutes=routing_workcenter.time_cycle)
|
||||||
|
item.date_planned_start = last_wo_start
|
||||||
|
record.sudo().production_id.plan_start_processing_time = item.date_planned_start
|
||||||
|
item.duration_expected = routing_workcenter.time_cycle
|
||||||
|
record.calculate_plan_time(item, item)
|
||||||
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 = '已排'
|
||||||
|
|||||||
Reference in New Issue
Block a user