增加AGV调度功能,工单页面增加自定义筛选字段
This commit is contained in:
@@ -9,3 +9,4 @@ from . import stock
|
||||
from . import res_user
|
||||
from . import production_line_base
|
||||
from . import agv_setting
|
||||
from . import agv_dispatch
|
||||
|
||||
50
sf_manufacturing/models/agv_dispatch.py
Normal file
50
sf_manufacturing/models/agv_dispatch.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from odoo import models, fields, api
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class AgvDispatch(models.Model):
|
||||
_name = 'sf.agv.dispatch'
|
||||
_description = 'agv调度'
|
||||
|
||||
name = fields.Char('任务单号')
|
||||
|
||||
def _get_agv_route_type_selection(self):
|
||||
return self.env['sf.agv.task.route'].fields_get(['route_type'])['route_type']['selection']
|
||||
|
||||
agv_route_type = fields.Selection(selection=_get_agv_route_type_selection, string='任务类型')
|
||||
agv_route_name = fields.Char('任务路线名称')
|
||||
start_site_id = fields.Many2one('sf.agv.site', '起点接驳站')
|
||||
end_site_id = fields.Many2one('sf.agv.site', '终点接驳站')
|
||||
site_state = fields.Selection([
|
||||
('占用', '占用'),
|
||||
('空闲', '空闲')], string='终点接驳站状态')
|
||||
state = fields.Selection([
|
||||
('待下发', '待下发'),
|
||||
('配送中', '配送中'),
|
||||
('已配送', '已配送'),
|
||||
('已取消', '已取消')], string='状态', default='待下发')
|
||||
workpiece_delivery_ids = fields.One2many('sf.workpiece.delivery', 'agv_dispatch_id', string='工件配送单')
|
||||
delivery_workpieces = fields.Char('配送工件', compute='_compute_delivery_workpieces')
|
||||
|
||||
@api.depends('workpiece_delivery_ids')
|
||||
def _compute_delivery_workpieces(self):
|
||||
for rec in self:
|
||||
rec.delivery_workpieces = '\\'.join(rec.workpiece_delivery_ids.mapped('name'))
|
||||
|
||||
task_create_time = fields.Datetime('任务创建时间')
|
||||
task_delivery_time = fields.Datetime('任务下发时间')
|
||||
task_completion_time = fields.Datetime('任务完成时间')
|
||||
task_duration = fields.Char('任务时长', compute='_compute_task_duration')
|
||||
|
||||
@api.depends('task_completion_time', 'task_delivery_time')
|
||||
def _compute_task_duration(self):
|
||||
for rec in self:
|
||||
if rec.task_completion_time and rec.task_delivery_time:
|
||||
rec.task_duration = str(rec.task_completion_time - rec.task_delivery_time)
|
||||
else:
|
||||
rec.task_duration = ''
|
||||
|
||||
def add_queue(self, vals):
|
||||
if not vals.get('agv_route_type') or vals.get('agv_route_type') not in self._get_agv_route_type_selection():
|
||||
raise ValidationError('无效的路线类型!')
|
||||
self.env['sf.agv.dispatch'].sudo().create(vals)
|
||||
@@ -11,12 +11,14 @@ class AgvSetting(models.Model):
|
||||
_description = 'agv站点'
|
||||
|
||||
name = fields.Char('位置编号')
|
||||
owning_region = fields.Char('所属区域')
|
||||
# owning_region = fields.Char('所属区域')
|
||||
state = fields.Selection([
|
||||
('占用', '占用'),
|
||||
('空闲', '空闲')], string='状态')
|
||||
divide_the_work = fields.Char('主要分工')
|
||||
active = fields.Boolean('有效', default=True)
|
||||
region = fields.Many2one(string='所属区域', comodel_name='mrp.workcenter', tracking=True,
|
||||
domain=[('is_agv_dispatch', '=', True)])
|
||||
|
||||
def update_site_state(self):
|
||||
# 调取中控的接驳站接口并修改对应站点的状态
|
||||
@@ -71,6 +73,15 @@ class AgvTaskRoute(models.Model):
|
||||
if self.end_site_id == self.start_site_id:
|
||||
raise UserError("您选择的终点接驳站与起点接驳站重复,请重新选择")
|
||||
|
||||
region = fields.Many2one(string='所属区域', comodel_name='mrp.workcenter', domain=[('is_agv_dispatch', '=', True)],
|
||||
compute="_compute_region")
|
||||
|
||||
@api.depends('end_site_id')
|
||||
def _compute_region(self):
|
||||
for record in self:
|
||||
if record.end_site_id:
|
||||
record.region = record.end_site_id.region
|
||||
|
||||
|
||||
class Center_controlInterfaceLog(models.Model):
|
||||
_name = 'center_control.interface.log'
|
||||
|
||||
@@ -124,6 +124,8 @@ class ResWorkcenter(models.Model):
|
||||
res[wc_id] = [(datetime.fromtimestamp(s), datetime.fromtimestamp(e)) for s, e, _ in final_intervals_wc]
|
||||
return res
|
||||
|
||||
# AGV是否可配送
|
||||
is_agv_dispatch = fields.Boolean(string="AGV配送", tracking=True)
|
||||
|
||||
class ResWorkcenterProductivity(models.Model):
|
||||
_inherit = 'mrp.workcenter.productivity'
|
||||
|
||||
@@ -1744,6 +1744,9 @@ class WorkPieceDelivery(models.Model):
|
||||
else:
|
||||
obj.delivery_duration = 0.0
|
||||
|
||||
# agv调度单
|
||||
agv_dispatch_id = fields.Many2one('sf.agv.dispatch', 'agv调度单')
|
||||
|
||||
|
||||
class CMMprogram(models.Model):
|
||||
_name = 'sf.cmm.program'
|
||||
|
||||
Reference in New Issue
Block a user