45 lines
1.7 KiB
Python
45 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
import base64
|
|
import logging
|
|
import os
|
|
from datetime import datetime
|
|
from odoo import fields, models
|
|
# from odoo.exceptions import ValidationError
|
|
from odoo.exceptions import UserError
|
|
from datetime import datetime, timedelta
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
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
|
|
|
|
def _get_production_line_id(self):
|
|
sf_production_line = self.env['sf.production.line'].sudo().search(
|
|
[('name', '=', '1#CNC自动生产线')], limit=1)
|
|
return sf_production_line.id
|
|
|
|
# 选择生产线
|
|
production_line_id = fields.Many2one('sf.production.line', string=u'生产线', required=True,
|
|
default=_get_production_line_id)
|
|
date_planned_start = fields.Datetime(string='计划开始时间', index=True, copy=False, required=True)
|
|
|
|
# 接收传递过来的计划ID
|
|
plan_ids = fields.Many2many('sf.production.plan', string=u'计划ID')
|
|
|
|
# 确认排程按钮
|
|
def action_plan_all(self):
|
|
# 使用传递过来的计划ID
|
|
self.plan_ids.production_line_id = self.production_line_id.id
|
|
self.plan_ids.date_planned_start = self.date_planned_start
|
|
# 在这里添加您的逻辑来处理这些ID
|
|
# 判断能否排成
|
|
self.plan_ids.do_production_schedule(self.date_planned_start)
|
|
_logger.info('处理计划: %s 完成', self.plan_ids.ids)
|