Accept Merge Request #1308: (feature/update_production_line -> develop)

Merge Request: 修改排程计划开始时间修改

Created By: @胡嘉莹
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @胡嘉莹
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1308
This commit is contained in:
胡嘉莹
2024-09-14 17:45:18 +08:00
committed by Coding
2 changed files with 9 additions and 6 deletions

View File

@@ -192,7 +192,7 @@ class sf_production_plan(models.Model):
return num
def do_production_schedule(self, date_planned_start):
def do_production_schedule(self):
"""
排程方法
"""
@@ -200,8 +200,7 @@ class sf_production_plan(models.Model):
if not record.production_line_id:
raise ValidationError("未选择生产线")
else:
is_schedule = self.deal_processing_schedule(date_planned_start)
is_schedule = self.deal_processing_schedule(record.date_planned_start)
if not is_schedule:
raise ValidationError("排程失败")
workorder_id_list = record.production_id.workorder_ids.ids
@@ -210,7 +209,6 @@ class sf_production_plan(models.Model):
for item in record.production_id.workorder_ids:
if item.name == 'CNC加工':
item.date_planned_finished = datetime.now() + timedelta(days=100)
# item.date_planned_start = record.date_planned_start
item.date_planned_start = self.date_planned_start if self.date_planned_start else datetime.now()
record.sudo().production_id.plan_start_processing_time = item.date_planned_start
item.date_planned_finished = item.date_planned_start + timedelta(

View File

@@ -15,10 +15,15 @@ class Action_Plan_All_Wizard(models.TransientModel):
_name = 'sf.action.plan.all.wizard'
_description = u'排程向导'
def _get_date_planned_start(self):
planned_start_date = datetime.now() + timedelta(minutes=10)
logging.info('计划开始时间: %s', planned_start_date)
return planned_start_date
# 选择生产线
production_line_id = fields.Many2one('sf.production.line', string=u'生产线', required=True)
date_planned_start = fields.Datetime(string='计划开始时间', index=True, copy=False,
default=datetime.now() + timedelta(minutes=10))
default=_get_date_planned_start)
# 接收传递过来的计划ID
plan_ids = fields.Many2many('sf.production.plan', string=u'计划ID')
@@ -37,7 +42,7 @@ class Action_Plan_All_Wizard(models.TransientModel):
plan_obj = self.env['sf.production.plan'].browse(plan.id)
plan_obj.production_line_id = self.production_line_id.id
plan.date_planned_start = self.date_planned_start
plan_obj.do_production_schedule(self.date_planned_start)
plan_obj.do_production_schedule()
# plan_obj.state = 'done'
print('处理计划:', plan.id, '完成')