增加agv配送重新下发与取消
This commit is contained in:
@@ -52,6 +52,8 @@
|
||||
'sf_manufacturing/static/src/scss/kanban_change.scss',
|
||||
'sf_manufacturing/static/src/xml/button_show_on_tree.xml',
|
||||
'sf_manufacturing/static/src/js/workpiece_delivery_wizard_confirm.js',
|
||||
'sf_manufacturing/static/src/js/agv_scheduling_resend_confirm.js',
|
||||
'sf_manufacturing/static/src/js/agv_scheduling_cancel_confirm.js',
|
||||
'sf_manufacturing/static/src/js/qr.js',
|
||||
'sf_manufacturing/static/src/xml/qr.xml',
|
||||
]
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -36,7 +36,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
store=True, check_company=True, string="材料")
|
||||
product_tmpl_id_materials_type_id = fields.Many2one(related='production_id.product_tmpl_id.materials_type_id',
|
||||
readonly=True, store=True, check_company=True, string="型号")
|
||||
workcenter_id = fields.Many2one('mrp.workcenter', string='工作中心', required=False)
|
||||
# workcenter_id = fields.Many2one('mrp.workcenter', string='工作中心', required=False)
|
||||
users_ids = fields.Many2many("res.users", 'users_workorder', related="workcenter_id.users_ids")
|
||||
processing_panel = fields.Char('加工面')
|
||||
sequence = fields.Integer(string='工序')
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
odoo.define('sf_manufacturing.agv_scheduling_button_confirm', function (require) {
|
||||
const core = require('web.core');
|
||||
const ajax = require('web.ajax');
|
||||
const Dialog = require('web.Dialog');
|
||||
var rpc = require('web.rpc');
|
||||
var _t = core._t;
|
||||
|
||||
async function agv_scheduling_cancel_confirm(parent, {params}) {
|
||||
const dialog = new Dialog(parent, {
|
||||
title: "确认",
|
||||
$content: $('<div>').append("工件正在配送中,确定取消"),
|
||||
buttons: [
|
||||
{ text: "确认", classes: 'btn-primary', close: true, click: () => dispatchConfirmed(parent, params) },
|
||||
{ text: "取消", close: true },
|
||||
],
|
||||
});
|
||||
dialog.open();
|
||||
|
||||
|
||||
async function dispatchConfirmed(parent, params) {
|
||||
rpc.query({
|
||||
model: 'sf.agv.scheduling',
|
||||
method: 'button_cancel',
|
||||
args: [params.agv_scheduling_id],
|
||||
kwargs: {
|
||||
context: params.context,
|
||||
}
|
||||
}).then(res => {
|
||||
parent.services.action.doAction({
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'display_notification',
|
||||
'target': 'new',
|
||||
'params': {
|
||||
'message': '取消成功!',
|
||||
'type': 'success',
|
||||
'sticky': false,
|
||||
'next': {'type': 'ir.actions.act_window_close'},
|
||||
}
|
||||
});
|
||||
parent.services.action.doAction({
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'reload',
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
core.action_registry.add('agv_scheduling_cancel_confirm', agv_scheduling_cancel_confirm);
|
||||
return agv_scheduling_cancel_confirm;
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
odoo.define('sf_manufacturing.agv_scheduling_resend_confirm', function (require) {
|
||||
const core = require('web.core');
|
||||
const ajax = require('web.ajax');
|
||||
const Dialog = require('web.Dialog');
|
||||
var rpc = require('web.rpc');
|
||||
var _t = core._t;
|
||||
|
||||
async function agv_scheduling_resend_confirm(parent, {params}) {
|
||||
const dialog = new Dialog(parent, {
|
||||
title: "确认",
|
||||
$content: $('<div>').append("工件正在配送中,确定重新下发"),
|
||||
buttons: [
|
||||
{ text: "确认", classes: 'btn-primary', close: true, click: () => dispatchConfirmed(parent, params) },
|
||||
{ text: "取消", close: true },
|
||||
],
|
||||
});
|
||||
dialog.open();
|
||||
|
||||
|
||||
async function dispatchConfirmed(parent, params) {
|
||||
rpc.query({
|
||||
model: 'sf.agv.scheduling',
|
||||
method: 'button_resend',
|
||||
args: [params.agv_scheduling_id],
|
||||
kwargs: {
|
||||
context: params.context,
|
||||
}
|
||||
}).then(res => {
|
||||
parent.services.action.doAction({
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'display_notification',
|
||||
'target': 'new',
|
||||
'params': {
|
||||
'message': '重新下发成功!',
|
||||
'type': 'success',
|
||||
'sticky': false,
|
||||
'next': {'type': 'ir.actions.act_window_close'},
|
||||
}
|
||||
});
|
||||
parent.services.action.doAction({
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'reload',
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
core.action_registry.add('agv_scheduling_resend_confirm', agv_scheduling_resend_confirm );
|
||||
return agv_scheduling_resend_confirm;
|
||||
});
|
||||
@@ -22,8 +22,7 @@ odoo.define('sf_manufacturing.action_dispatch_confirm', function (require) {
|
||||
rpc.query({
|
||||
model: 'sf.workpiece.delivery.wizard',
|
||||
method: 'confirm',
|
||||
args: [params.active_id]
|
||||
,
|
||||
args: [params.active_id],
|
||||
kwargs: {
|
||||
context: params.context,
|
||||
}
|
||||
|
||||
@@ -33,6 +33,20 @@
|
||||
class="btn-danger"
|
||||
confirm="你确定要取消这条记录吗?"
|
||||
/>
|
||||
<button
|
||||
name="button_cancel_confirm"
|
||||
string="取消" type="object"
|
||||
attrs="{'invisible': [('state', '!=', '配送中')]}"
|
||||
icon="fa-times"
|
||||
class="btn-danger"
|
||||
/>
|
||||
<button
|
||||
name="button_resend_confirm"
|
||||
string="重新下发" type="object"
|
||||
attrs="{'invisible': [('state', '!=', '配送中')]}"
|
||||
icon="fa-circle-o-notch"
|
||||
class="btn-success "
|
||||
/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user