Accept Merge Request #872: (feature/修改机床参数bug -> develop)
Merge Request: 修改设备oee自动生成,设备刀库编码规则 Created By: @龚启豪 Reviewed By: @马广威 Approved By: @马广威 Accepted By: @马广威 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/872#mr-872-review-128778
This commit is contained in:
@@ -13,7 +13,7 @@ class SfMaintenanceEquipmentCategory(models.Model):
|
|||||||
_description = '设备类别'
|
_description = '设备类别'
|
||||||
|
|
||||||
equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'),
|
equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'),
|
||||||
('检测设备', '检测设备')], string='类型', default='机床')
|
('检测设备', '检测设备'), ('其他', '其他')], string='类型', default='机床')
|
||||||
equipment_type_code = fields.Char('简写')
|
equipment_type_code = fields.Char('简写')
|
||||||
|
|
||||||
|
|
||||||
@@ -104,18 +104,18 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
tool_diameter_max = fields.Char('刀具刀径max(mm)')
|
tool_diameter_max = fields.Char('刀具刀径max(mm)')
|
||||||
tool_diameter_min = fields.Char('刀具刀径min(mm)')
|
tool_diameter_min = fields.Char('刀具刀径min(mm)')
|
||||||
|
|
||||||
def get_no(self):
|
# def get_no(self):
|
||||||
partner = self.env['maintenance.equipment'].sudo().search(
|
# partner = self.env['maintenance.equipment'].sudo().search(
|
||||||
[('MTcode', '!=', '')],
|
# [('MTcode', '!=', '')],
|
||||||
limit=1,
|
# limit=1,
|
||||||
order="id desc")
|
# order="id desc")
|
||||||
if not partner:
|
# if not partner:
|
||||||
num = "%04d" % 1
|
# num = "%04d" % 1
|
||||||
|
#
|
||||||
else:
|
# else:
|
||||||
m = int(partner.MTcode) + 1
|
# m = int(partner.MTcode) + 1
|
||||||
num = "%04d" % m
|
# num = "%04d" % m
|
||||||
return num
|
# return num
|
||||||
|
|
||||||
|
|
||||||
equipment_maintenance_standards_ids = fields.Many2many('equipment.maintenance.standards',
|
equipment_maintenance_standards_ids = fields.Many2many('equipment.maintenance.standards',
|
||||||
@@ -145,7 +145,7 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
else:
|
else:
|
||||||
record.equipment_maintenance_standards_ids = False
|
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)
|
created_user = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user)
|
||||||
equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'),
|
equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'),
|
||||||
('检测设备', '检测设备')], compute='_compute_category_id')
|
('检测设备', '检测设备')], compute='_compute_category_id')
|
||||||
@@ -178,7 +178,7 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
type_id = fields.Many2one('sf.machine_tool.type', '型号')
|
type_id = fields.Many2one('sf.machine_tool.type', '型号')
|
||||||
|
|
||||||
state = fields.Selection(
|
state = fields.Selection(
|
||||||
[("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"),("空闲", "空闲"),("封存(报废)", "封存(报废)")],
|
[("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"), ("空闲", "空闲"), ("封存(报废)", "封存(报废)")],
|
||||||
default='正常', string="机床状态")
|
default='正常', string="机床状态")
|
||||||
run_time = fields.Char('总运行时长')
|
run_time = fields.Char('总运行时长')
|
||||||
# 0606新增字段
|
# 0606新增字段
|
||||||
@@ -230,7 +230,15 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
|
|
||||||
equipment = super(SfMaintenanceEquipment, self).create(vals)
|
equipment = super(SfMaintenanceEquipment, self).create(vals)
|
||||||
if equipment.category_id:
|
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,
|
'T_tool_time': item.T_tool_time,
|
||||||
'C_tool_time': item.C_tool_time,
|
'C_tool_time': item.C_tool_time,
|
||||||
'jiancheng': item.category_id.equipment_type_code,
|
'jiancheng': item.category_id.equipment_type_code,
|
||||||
'function_type': item.function_type,
|
|
||||||
}
|
}
|
||||||
machine_tool_list.append(val)
|
machine_tool_list.append(val)
|
||||||
# kw = machine_tool_list
|
# kw = machine_tool_list
|
||||||
|
|||||||
@@ -36,8 +36,7 @@
|
|||||||
type="action"
|
type="action"
|
||||||
class="oe_stat_button"
|
class="oe_stat_button"
|
||||||
context="{'search_default_equipment_id': [active_id]}"
|
context="{'search_default_equipment_id': [active_id]}"
|
||||||
icon="fa-exchange"
|
icon="fa-exchange">
|
||||||
attrs="{'invisible': [('state_zc', '!=', '已注册')]}">
|
|
||||||
<field string="设备oee" name="equipment_oee_ids" widget="statinfo"/>
|
<field string="设备oee" name="equipment_oee_ids" widget="statinfo"/>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|||||||
@@ -22,10 +22,19 @@ class ResMrpRoutingWorkcenter(models.Model):
|
|||||||
bom_id = fields.Many2one('mrp.bom', required=False)
|
bom_id = fields.Many2one('mrp.bom', required=False)
|
||||||
surface_technics_id = fields.Many2one('sf.production.process', string="表面工艺")
|
surface_technics_id = fields.Many2one('sf.production.process', string="表面工艺")
|
||||||
|
|
||||||
def generate_code(self):
|
def get_no(self):
|
||||||
return self.env['ir.sequence'].next_by_code('mrp.routing.workcenter')
|
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):
|
def get_company_id(self):
|
||||||
|
|||||||
@@ -859,7 +859,7 @@ class SfMaintenanceEquipmentAndProductTemplate(models.Model):
|
|||||||
for i in range(1, number + 1):
|
for i in range(1, number + 1):
|
||||||
self.env['maintenance.equipment.tool'].create({
|
self.env['maintenance.equipment.tool'].create({
|
||||||
'equipment_id': res.id,
|
'equipment_id': res.id,
|
||||||
'code': 'T' + str(i)
|
'code': "T%02d" % i
|
||||||
})
|
})
|
||||||
vals.append(res)
|
vals.append(res)
|
||||||
return vals[0]
|
return vals[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user