修改设备oee自动生成,设备刀库编码规则
This commit is contained in:
@@ -13,7 +13,7 @@ class SfMaintenanceEquipmentCategory(models.Model):
|
||||
_description = '设备类别'
|
||||
|
||||
equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'),
|
||||
('检测设备', '检测设备')], string='类型', default='机床')
|
||||
('检测设备', '检测设备'), ('其他', '其他')], string='类型', default='机床')
|
||||
equipment_type_code = fields.Char('简写')
|
||||
|
||||
|
||||
@@ -104,18 +104,18 @@ class SfMaintenanceEquipment(models.Model):
|
||||
tool_diameter_max = fields.Char('刀具刀径max(mm)')
|
||||
tool_diameter_min = fields.Char('刀具刀径min(mm)')
|
||||
|
||||
def get_no(self):
|
||||
partner = self.env['maintenance.equipment'].sudo().search(
|
||||
[('MTcode', '!=', '')],
|
||||
limit=1,
|
||||
order="id desc")
|
||||
if not partner:
|
||||
num = "%04d" % 1
|
||||
|
||||
else:
|
||||
m = int(partner.MTcode) + 1
|
||||
num = "%04d" % m
|
||||
return num
|
||||
# def get_no(self):
|
||||
# partner = self.env['maintenance.equipment'].sudo().search(
|
||||
# [('MTcode', '!=', '')],
|
||||
# limit=1,
|
||||
# order="id desc")
|
||||
# if not partner:
|
||||
# num = "%04d" % 1
|
||||
#
|
||||
# else:
|
||||
# m = int(partner.MTcode) + 1
|
||||
# num = "%04d" % m
|
||||
# return num
|
||||
|
||||
|
||||
equipment_maintenance_standards_ids = fields.Many2many('equipment.maintenance.standards',
|
||||
@@ -145,7 +145,7 @@ class SfMaintenanceEquipment(models.Model):
|
||||
else:
|
||||
record.equipment_maintenance_standards_ids = False
|
||||
|
||||
MTcode = fields.Char("机台编码", default=get_no)
|
||||
MTcode = fields.Char("机台编码")
|
||||
created_user = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user)
|
||||
equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'),
|
||||
('检测设备', '检测设备')], compute='_compute_category_id')
|
||||
@@ -178,7 +178,7 @@ class SfMaintenanceEquipment(models.Model):
|
||||
type_id = fields.Many2one('sf.machine_tool.type', '型号')
|
||||
|
||||
state = fields.Selection(
|
||||
[("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"),("空闲", "空闲"),("封存(报废)", "封存(报废)")],
|
||||
[("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"), ("空闲", "空闲"), ("封存(报废)", "封存(报废)")],
|
||||
default='正常', string="机床状态")
|
||||
run_time = fields.Char('总运行时长')
|
||||
# 0606新增字段
|
||||
@@ -230,7 +230,15 @@ class SfMaintenanceEquipment(models.Model):
|
||||
|
||||
equipment = super(SfMaintenanceEquipment, self).create(vals)
|
||||
if equipment.category_id:
|
||||
equipment.name = equipment.MTcode + '#' + equipment.category_id.name
|
||||
equipment.name = "%s%s" % (equipment.MTcode, equipment.category_id.name)
|
||||
if equipment.category_id.equipment_type == '机床':
|
||||
equipment_id = self.env['maintenance.equipment.oee'].search([('equipment_id', '=', equipment.id)])
|
||||
if not equipment_id:
|
||||
self.env['maintenance.equipment.oee'].sudo().create({
|
||||
'equipment_id': equipment.id,
|
||||
'name': equipment.name,
|
||||
|
||||
})
|
||||
|
||||
# 在创建设备之后执行一些自定义逻辑
|
||||
# ...
|
||||
@@ -567,7 +575,6 @@ class SfMaintenanceEquipment(models.Model):
|
||||
'T_tool_time': item.T_tool_time,
|
||||
'C_tool_time': item.C_tool_time,
|
||||
'jiancheng': item.category_id.equipment_type_code,
|
||||
'function_type': item.function_type,
|
||||
}
|
||||
machine_tool_list.append(val)
|
||||
# kw = machine_tool_list
|
||||
|
||||
Reference in New Issue
Block a user