增加中控接口返回对工单、计划单属性的改变(状态,时间等)

This commit is contained in:
mgw
2024-02-27 11:42:59 +08:00
parent dfada55cf7
commit fdddf19d13
5 changed files with 62 additions and 15 deletions

View File

@@ -52,10 +52,10 @@ class sf_production_plan(models.Model):
('reverse', '倒排'), ('positive', '顺排')], string='排程设置', default='reverse')
product_id = fields.Many2one('product.product', '关联产品')
origin = fields.Char(string='订单号')
# 加工时长
process_time = fields.Float(string='加工时长', digits=(16, 2))
# # 加工时长
# process_time = fields.Float(string='加工时长', digits=(16, 2))
# 实际加工时长、实际开始时间、实际结束时间
actual_process_time = fields.Float(string='实际加工时长', digits=(16, 2))
actual_process_time = fields.Float(string='实际加工时长(分钟)', digits=(16, 2), compute='_compute_actual_process_time')
actual_start_time = fields.Datetime(string='实际开始时间')
actual_end_time = fields.Datetime(string='实际结束时间')
shift = fields.Char(string='班次')
@@ -67,16 +67,25 @@ class sf_production_plan(models.Model):
sequence = fields.Integer(string='序号', copy=False, readonly=True, index=True)
current_operation_name = fields.Char(string='当前工序名称', size=64, default='生产计划')
# 计算实际加工时长
@api.depends('actual_start_time', 'actual_end_time')
def _compute_actual_process_time(self):
for item in self:
if item.actual_start_time and item.actual_end_time:
item.actual_process_time = (item.actual_end_time - item.actual_start_time).total_seconds() / 60
else:
item.actual_process_time = None
@api.onchange('production_line_id')
def _compute_production_line_id(self):
for item in self:
item.sudo().production_id.production_line_id = item.production_line_id.id
item.sudo().production_id.plan_start_processing_time = item.date_planned_start
@api.onchange('state')
def _onchange_state(self):
if self.state == 'finished':
self.production_id.schedule_state = '已完成'
# @api.onchange('state')
# def _onchange_state(self):
# if self.state == 'finished':
# self.production_id.schedule_state = '已完成'
# @api.model
# def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None):