修改维保生成编码和名称的规则

This commit is contained in:
qihao.gong@jikimo.com
2023-09-26 17:29:14 +08:00
parent 9c2d4dbc24
commit 22a4ccad6b
8 changed files with 38 additions and 12 deletions

View File

@@ -15,13 +15,31 @@ class SfEquipmentSaintenanceStandards(models.Model):
num = "%04d" % 1 num = "%04d" % 1
else: else:
m = int(partner.code) + 1 m = int(partner.code[-4:]) + 1
num = "%04d" % m num = "%04d" % m
return num return num
code = fields.Char(string='编码', default=get_no) code = fields.Char(string='编码')
remark = fields.Char('备注') remark = fields.Char('备注')
maintenance_type = fields.Selection([('保养', '保养'), ("检修", "检修")], string='类型', default='保养') maintenance_type = fields.Selection([('保养', '保养'), ("检修", "检修")], string='类型', default='保养')
name = fields.Char(string='名称') name = fields.Char(string='名称')
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if not vals['code']:
if vals['maintenance_type']:
if vals['maintenance_type'] == '保养':
vals['code'] = 'BY' + self.get_no()
else:
vals['code'] = 'JX' + self.get_no()
if not vals['name']:
if vals['maintenance_equipment_category_id']:
ma_name = self.env['maintenance.equipment.category'].sudo().search(
[('id', '=', vals['maintenance_equipment_category_id'])]).name
vals['name'] = ma_name + '-' + vals['maintenance_type'] + '标准-' + vals[
'code']
return super().create(vals_list)
created_user_id = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user) created_user_id = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user)
maintenance_equipment_category_id = fields.Many2one('maintenance.equipment.category', string='设备类别') maintenance_equipment_category_id = fields.Many2one('maintenance.equipment.category', string='设备类别')
maintenance_equipment_ids = fields.Many2many( maintenance_equipment_ids = fields.Many2many(

View File

@@ -11,7 +11,7 @@
<group> <group>
<group> <group>
<field name="code" readonly="1" force_save="1"/> <field name="code" readonly="1" force_save="1"/>
<field name="name" required="1"/> <field name="name" readonly="1" force_save="1"/>
<field name="maintenance_equipment_category_id" required="1"/> <field name="maintenance_equipment_category_id" required="1"/>
<field name="eq_maintenance_ids" invisible='1'/> <field name="eq_maintenance_ids" invisible='1'/>
<field name="overhaul_ids" invisible='1'/> <field name="overhaul_ids" invisible='1'/>

View File

@@ -18,9 +18,9 @@
'views/mrp_production_addional_change.xml', 'views/mrp_production_addional_change.xml',
# 'views/mrp_maintenance_views.xml', # 'views/mrp_maintenance_views.xml',
'views/mrp_routing_workcenter_view.xml', 'views/mrp_routing_workcenter_view.xml',
'views/production_line_view.xml',
'views/mrp_workcenter_views.xml', 'views/mrp_workcenter_views.xml',
'views/mrp_workorder_view.xml', 'views/mrp_workorder_view.xml',
'views/production_line_view.xml',
'views/tool_other_features_view.xml', 'views/tool_other_features_view.xml',
'views/model_type_view.xml', 'views/model_type_view.xml',
# 'views/kanban_change.xml' # 'views/kanban_change.xml'

View File

@@ -6,8 +6,8 @@ from dateutil.relativedelta import relativedelta
class MaintenanceEquipment(models.Model): class MaintenanceEquipment(models.Model):
_inherit = "maintenance.equipment" _inherit = "maintenance.equipment"
_check_company_auto = True
production_line_id = fields.Many2one('sf.production.line', string='生产线')
expected_mtbf = fields.Integer(string='Expected MTBF', help='Expected Mean Time Between Failure') expected_mtbf = fields.Integer(string='Expected MTBF', help='Expected Mean Time Between Failure')
mtbf = fields.Integer(compute='_compute_maintenance_request', string='MTBF', mtbf = fields.Integer(compute='_compute_maintenance_request', string='MTBF',
help='Mean Time Between Failure, computed based on done corrective maintenances.') help='Mean Time Between Failure, computed based on done corrective maintenances.')
@@ -16,8 +16,6 @@ class MaintenanceEquipment(models.Model):
string='Estimated time before next failure (in days)', string='Estimated time before next failure (in days)',
help='Computed as Latest Failure Date + MTBF') help='Computed as Latest Failure Date + MTBF')
latest_failure_date = fields.Date(compute='_compute_maintenance_request', string='Latest Failure Date') latest_failure_date = fields.Date(compute='_compute_maintenance_request', string='Latest Failure Date')
workcenter_id = fields.Many2one(
'mrp.workcenter', string='Work Center', check_company=True)
@api.depends('effective_date', 'maintenance_ids.stage_id', 'maintenance_ids.close_date', @api.depends('effective_date', 'maintenance_ids.stage_id', 'maintenance_ids.close_date',
'maintenance_ids.request_date') 'maintenance_ids.request_date')

View File

@@ -10,12 +10,10 @@ class ResWorkcenter(models.Model):
# 生产线显示 # 生产线显示
production_line_show = fields.Char(string='生产线名称') production_line_show = fields.Char(string='生产线名称')
machine_tool_id = fields.Many2one('sf.machine_tool', string='机床') machine_tool_id = fields.Many2one('sf.machine_tool', string='机床')
production_line_id = fields.Many2one('sf.production.line', string='生产线')
equipment_id = fields.Many2one( equipment_id = fields.Many2one(
'maintenance.equipment', string="设备", 'maintenance.equipment', string="设备",
check_company=True) )
production_line_id = fields.Many2one('sf.production.line', string='生产线')
is_process_outsourcing = fields.Boolean('工艺外协') is_process_outsourcing = fields.Boolean('工艺外协')
users_ids = fields.Many2many("res.users", 'users_workcenter') users_ids = fields.Many2many("res.users", 'users_workcenter')

View File

@@ -22,6 +22,7 @@ class ProductionLine(models.Model):
return num return num
mrp_workcenter_ids = fields.One2many('mrp.workcenter', 'production_line_id', '工作中心') mrp_workcenter_ids = fields.One2many('mrp.workcenter', 'production_line_id', '工作中心')
mrp_manufacturing_ids = fields.One2many('maintenance.equipment', 'production_line_id', '设备')
name = fields.Char('生产线', size=20, required=True) name = fields.Char('生产线', size=20, required=True)
code = fields.Char('编码', default=_get_code, readonly=True) code = fields.Char('编码', default=_get_code, readonly=True)
remark = fields.Char('备注') remark = fields.Char('备注')

View File

@@ -162,7 +162,7 @@
<field name="equipment_status"/> <field name="equipment_status"/>
</xpath> </xpath>
<xpath expr="//field[@name='alternative_workcenter_ids']" position="after"> <xpath expr="//field[@name='alternative_workcenter_ids']" position="after">
<field name="production_line_id"/> <field name="production_line_id" readonly="1"/>
<field name="equipment_id"/> <field name="equipment_id"/>
<field name="production_line_show" invisible="1"/> <field name="production_line_show" invisible="1"/>
</xpath> </xpath>

View File

@@ -82,4 +82,15 @@
name="生产线" name="生产线"
sequence="20" sequence="20"
action="sf_production_line_act"/> action="sf_production_line_act"/>
<record id="sf_hr_equipment_view_form_manufacturing" model="ir.ui.view">
<field name="name">sf_equipment.form</field>
<field name="model">maintenance.equipment</field>
<field name="inherit_id" ref="sf_maintenance.sf_hr_equipment_view_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='brand_id']" position="after">
<field name="production_line_id"/>
</xpath>
</field>
</record>
</odoo> </odoo>