修改设备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
|
||||
|
||||
@@ -36,8 +36,7 @@
|
||||
type="action"
|
||||
class="oe_stat_button"
|
||||
context="{'search_default_equipment_id': [active_id]}"
|
||||
icon="fa-exchange"
|
||||
attrs="{'invisible': [('state_zc', '!=', '已注册')]}">
|
||||
icon="fa-exchange">
|
||||
<field string="设备oee" name="equipment_oee_ids" widget="statinfo"/>
|
||||
</button>
|
||||
|
||||
|
||||
@@ -22,10 +22,19 @@ class ResMrpRoutingWorkcenter(models.Model):
|
||||
bom_id = fields.Many2one('mrp.bom', required=False)
|
||||
surface_technics_id = fields.Many2one('sf.production.process', string="表面工艺")
|
||||
|
||||
def generate_code(self):
|
||||
return self.env['ir.sequence'].next_by_code('mrp.routing.workcenter')
|
||||
def get_no(self):
|
||||
international_standards = self.search(
|
||||
[('code', '!=', ''), ('active', 'in', [True, False])],
|
||||
limit=1,
|
||||
order="id desc")
|
||||
if not international_standards:
|
||||
num = "%03d" % 1
|
||||
else:
|
||||
m = int(international_standards.code) + 1
|
||||
num = "%03d" % m
|
||||
return num
|
||||
|
||||
code = fields.Char('编码', default=generate_code)
|
||||
code = fields.Char('编码', default=get_no)
|
||||
|
||||
# 获得当前登陆者公司
|
||||
def get_company_id(self):
|
||||
|
||||
@@ -859,7 +859,7 @@ class SfMaintenanceEquipmentAndProductTemplate(models.Model):
|
||||
for i in range(1, number + 1):
|
||||
self.env['maintenance.equipment.tool'].create({
|
||||
'equipment_id': res.id,
|
||||
'code': 'T' + str(i)
|
||||
'code': "T%02d" % i
|
||||
})
|
||||
vals.append(res)
|
||||
return vals[0]
|
||||
|
||||
Reference in New Issue
Block a user