增加agv配送重新下发与取消
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
import logging
|
||||
import requests
|
||||
from datetime import timedelta
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import UserError
|
||||
@@ -210,9 +211,18 @@ class AgvScheduling(models.Model):
|
||||
def button_cancel(self):
|
||||
# 弹出二次确认窗口后执行
|
||||
for rec in self:
|
||||
if rec.state != '待下发':
|
||||
raise UserError('只有待下发状态的AGV调度任务才能取消!')
|
||||
rec.state = '已取消'
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'display_notification',
|
||||
'target': 'new',
|
||||
'params': {
|
||||
'message': '任务取消成功!',
|
||||
'type': 'success',
|
||||
'sticky': False,
|
||||
'next': {'type': 'ir.actions.act_window_close'},
|
||||
}
|
||||
}
|
||||
|
||||
def finish_scheduling(self):
|
||||
"""
|
||||
@@ -232,7 +242,7 @@ class AgvScheduling(models.Model):
|
||||
agv_route sf.agv.task.route对象
|
||||
"""
|
||||
for rec in self:
|
||||
if rec.state != '待下发':
|
||||
if rec.state not in ['待下发', '配送中']:
|
||||
return False
|
||||
_logger.info('AGV任务调度:下发调度任务,路线为%s' % agv_task_route)
|
||||
rec.state = '配送中'
|
||||
@@ -264,7 +274,45 @@ class AgvScheduling(models.Model):
|
||||
'task_delivery_time': fields.Datetime.now()
|
||||
})
|
||||
return super().write(vals)
|
||||
|
||||
def button_cancel_confirm(self):
|
||||
if self.task_delivery_time > fields.Datetime.now() - timedelta(minutes=10):
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'agv_scheduling_cancel_confirm',
|
||||
'params': {
|
||||
'agv_scheduling_id': self.id,
|
||||
}
|
||||
}
|
||||
else:
|
||||
return self.button_cancel()
|
||||
|
||||
def button_resend_confirm(self):
|
||||
if self.task_delivery_time > fields.Datetime.now() - timedelta(minutes=10):
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'agv_scheduling_resend_confirm',
|
||||
'params': {
|
||||
'agv_scheduling_id': self.id,
|
||||
'context': self.env.context,
|
||||
}
|
||||
}
|
||||
else:
|
||||
return self.button_resend()
|
||||
|
||||
def button_resend(self):
|
||||
self.dispatch_scheduling(self.agv_route_id)
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'display_notification',
|
||||
'target': 'new',
|
||||
'params': {
|
||||
'message': '任务重新下发成功!',
|
||||
'type': 'success',
|
||||
'sticky': False,
|
||||
'next': {'type': 'ir.actions.act_window_close'},
|
||||
}
|
||||
}
|
||||
|
||||
class ResMrpWorkOrder(models.Model):
|
||||
_inherit = 'mrp.workorder'
|
||||
|
||||
Reference in New Issue
Block a user