diff --git a/sf_manufacturing/models/mrp_workcenter.py b/sf_manufacturing/models/mrp_workcenter.py index 9434651c..e18472d7 100644 --- a/sf_manufacturing/models/mrp_workcenter.py +++ b/sf_manufacturing/models/mrp_workcenter.py @@ -256,14 +256,12 @@ class ResWorkcenter(models.Model): date_planned_end), ('state', 'not in', ['draft', 'cancel'])]) - if plan_ids: - sum_qty = sum([p.product_qty for p in plan_ids]) - production_line_hour_capacity = self.production_line_hour_capacity - if sum_qty >= production_line_hour_capacity: - message = '当前计划开始时间不能预约排程,超过生产线小时产能(%d件)%d件' % ( - production_line_hour_capacity, count) - raise UserError(message) - return False + sum_qty = sum([p.product_qty for p in plan_ids]) if plan_ids else count + production_line_hour_capacity = self.production_line_hour_capacity + if sum_qty > production_line_hour_capacity: + message = '当前计划开始时间不能预约排程,超过生产线小时产能(%d件)%d件' % ( + production_line_hour_capacity, count) + raise UserError(message) return True diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py index 5f4003da..af5b387f 100644 --- a/sf_plan/models/custom_plan.py +++ b/sf_plan/models/custom_plan.py @@ -228,6 +228,7 @@ class sf_production_plan(models.Model): """ 排程方法 """ + self.deal_processing_schedule(self.date_planned_start) for record in self: if not record.production_line_id: raise ValidationError("未选择生产线") diff --git a/sf_plan/wizard/action_plan_some.py b/sf_plan/wizard/action_plan_some.py index f27f4dad..78726c4d 100644 --- a/sf_plan/wizard/action_plan_some.py +++ b/sf_plan/wizard/action_plan_some.py @@ -40,6 +40,5 @@ class Action_Plan_All_Wizard(models.TransientModel): self.plan_ids.date_planned_start = self.date_planned_start # 在这里添加您的逻辑来处理这些ID # 判断能否排成 - self.plan_ids.deal_processing_schedule(self.date_planned_start) self.plan_ids.do_production_schedule() _logger.info('处理计划: %s 完成', self.plan_ids.ids)