Files
test/sf_maintenance/models/sf_maintenance_oee.py
qihao.gong@jikimo.com fc7c66c615 AGV增加运行日志
设备oee增加运行日志
2024-01-24 17:29:42 +08:00

50 lines
2.5 KiB
Python

# -*- coding: utf-8 -*-
from odoo import api, fields, models, _
class SfMaintenanceEquipmentOEE(models.Model):
_name = 'maintenance.equipment.oee'
_description = '设备OEE'
name = fields.Char('设备oee')
equipment_id = fields.Many2one('maintenance.equipment', '设备',
domain="[('category_id.equipment_type', '=', '机床'),('state_zc', '=', '已注册')]")
type_id = fields.Many2one('sf.machine_tool.type', '型号', related='equipment_id.type_id')
machine_tool_picture = fields.Binary('设备图片', related='equipment_id.machine_tool_picture')
state = fields.Selection(
[("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"), ("空闲", "空闲"),
("封存(报废)", "封存(报废)")],
default='正常', string="机床状态", related='equipment_id.state')
run_time = fields.Float('正常运行总时长(h)')
equipment_time = fields.Float('总时长(h)')
done_nums = fields.Integer('累计加工总件数')
utilization_rate = fields.Char('开动率')
fault_time = fields.Float('故障停机总时长(h)')
fault_nums = fields.Integer('故障次数')
sf_maintenance_logs_ids = fields.One2many('sf.maintenance.logs', 'maintenance_equipment_oee_id', '设备故障日志',
related='equipment_id.sf_maintenance_logs_ids')
oee_logs = fields.One2many('maintenance.equipment.oee.logs', 'equipment_oee_id', string='运行日志')
def name_get(self):
result = []
for parameter in self:
if parameter.equipment_id:
name = parameter.equipment_id.name
result.append((parameter.id, name))
return result
class SfMaintenanceEquipmentOEELog(models.Model):
_name = 'maintenance.equipment.oee.logs'
_description = '设备运行日志'
name = fields.Char('运行日志')
run_time = fields.Datetime('时间')
state = fields.Selection([("开机", "开机"), ("关机", "关机"), ("等待", "等待"), ("开始加工", "开始加工"),
("结束加工", "结束加工"), ("故障", "故障"),
("检修", "检修"), ("保养", "保养")], default="", string="事件/状态")
workorder_id = fields.Char('加工订单')
time = fields.Char('持续时长')
color = fields.Char('颜色', default=1)
equipment_oee_id = fields.Many2one('maintenance.equipment.oee', '设备OEE')