处理设备与设备维保标准的关联关系方法,新增设备故障报警日志页面
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
# -*-coding:utf-8-*-
|
||||
from . import sf_maintenance
|
||||
from . import sf_maintenance_logs
|
||||
from . import sf_equipment_maintenance_standards
|
||||
from . import sf_maintenance_requests
|
||||
@@ -26,3 +26,19 @@ class SfEquipmentSaintenanceStandards(models.Model):
|
||||
maintenance_equipment_ids = fields.Many2many('maintenance.equipment', 'sf_maintenance_equipment_ids', string='设备')
|
||||
maintenance_projects = fields.Char('维保项目')
|
||||
maintenance_standards = fields.Char('维保标准')
|
||||
eq_maintenance_ids = fields.One2many('maintenance.equipment', 'eq_maintenance_id', string='保养设备')
|
||||
overhaul_ids = fields.One2many('maintenance.equipment', 'overhaul_id', string='检修设备')
|
||||
|
||||
@api.onchange('maintenance_equipment_ids')
|
||||
def onchange_maintenance_equipment_ids(self):
|
||||
for record in self:
|
||||
if record.maintenance_type == '保养':
|
||||
record.write({'eq_maintenance_ids': [(6, 0, record.maintenance_equipment_ids.ids)]})
|
||||
if record.maintenance_type == '检修':
|
||||
record.write({'overhaul_ids': [(6, 0, record.maintenance_equipment_ids.ids)]})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
24
sf_maintenance/models/sf_maintenance_logs.py
Normal file
24
sf_maintenance/models/sf_maintenance_logs.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# -*-coding:utf-8-*-
|
||||
from odoo import fields, models
|
||||
|
||||
class SfMaintenanceLogs(models.Model):
|
||||
_name = 'sf.maintenance.logs'
|
||||
_description = '设备故障日志'
|
||||
|
||||
code = fields.Char(string='编码')
|
||||
name = fields.Char(string='名称')
|
||||
type = fields.Selection([('type1', '类型1'), ('type2', '类型2')], string='类型')
|
||||
brand = fields.Char(string='品牌')
|
||||
model = fields.Char(string='型号')
|
||||
code_location = fields.Char(string='编码位置')
|
||||
fault_type = fields.Selection([('电气类', '电气类'), ('机械类', '机械类'), ('程序类', '程序类'), ('系统类', '系统类')], string='故障类型')
|
||||
fault_code = fields.Char(string='故障代码')
|
||||
fault_alarm_info = fields.Char(string='故障报警信息')
|
||||
alarm_level = fields.Selection([('一级', '一级(严重)'), ('二级', '二级(中等)'), ('三级', '三级(轻微)')], string='报警级别')
|
||||
alarm_time = fields.Datetime(string='报警时间')
|
||||
alarm_way = fields.Selection([('文本提示报警', '文本提示报警'), ('声光报警', '声光报警'), ('图文报警', '图文报警')], string='报警方式')
|
||||
fault_process = fields.Text(string='故障处理方法')
|
||||
operator = fields.Many2one('res.users', string='处理人')
|
||||
recovery_time = fields.Datetime(string='复原时间')
|
||||
fault_duration = fields.Float(string='故障时长')
|
||||
note = fields.Text(string='备注')
|
||||
@@ -19,10 +19,23 @@ class SfMaintenanceEquipmentCategory(models.Model):
|
||||
for record in self:
|
||||
if record.sf_maintenance_type == '保养':
|
||||
record.equipment_maintenance_id = record.equipment_id.eq_maintenance_id
|
||||
|
||||
if record.sf_maintenance_type == '检修':
|
||||
record.equipment_maintenance_id = record.equipment_id.overhaul_id
|
||||
if not record.equipment_maintenance_id:
|
||||
raise UserError(_("设备没有配置维保标准,请配置后再保存"))
|
||||
record.equipment_maintenance_id = False
|
||||
|
||||
|
||||
maintenance_projects = fields.Char(string='维保项目', related='equipment_maintenance_id.maintenance_projects')
|
||||
maintenance_standards = fields.Char(string='维保标准', related='equipment_maintenance_id.maintenance_standards')
|
||||
|
||||
@api.constrains('equipment_maintenance_id')
|
||||
def _check_equipment_maintenance_id(self):
|
||||
for record in self:
|
||||
if not record.equipment_maintenance_id:
|
||||
raise UserError(_("设备维保标准不能为空,请选择后再保存"))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user