设备维保计划

This commit is contained in:
qihao.gong@jikimo.com
2023-06-26 17:32:56 +08:00
parent 8b227d9ac9
commit cf91ef5604
6 changed files with 109 additions and 50 deletions

View File

@@ -1,3 +1,4 @@
# -*-coding:utf-8-*- # -*-coding:utf-8-*-
from . import sf_maintenance from . import sf_maintenance
from . import sf_equipment_maintenance_standards from . import sf_equipment_maintenance_standards
from . import sf_maintenance_requests

View File

@@ -23,6 +23,6 @@ class SfEquipmentSaintenanceStandards(models.Model):
name = fields.Char(string='名称') name = fields.Char(string='名称')
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', 'equipment_maintenance_standards_ids', string='设备') maintenance_equipment_ids = fields.Many2many('maintenance.equipment', 'sf_maintenance_equipment_ids', string='设备')
maintenance_projects = fields.Char('维保项目') maintenance_projects = fields.Char('维保项目')
maintenance_standards = fields.Char('维保标准') maintenance_standards = fields.Char('维保标准')

View File

@@ -33,7 +33,7 @@ class SfMaintenanceEquipment(models.Model):
num = "%04d" % m num = "%04d" % m
return num return num
equipment_maintenance_standards_ids = fields.Many2many('equipment.maintenance.standards', 'maintenance_equipment_ids', string='设备维保标准') equipment_maintenance_standards_ids = fields.Many2many('equipment.maintenance.standards', 'sf_maintenance_equipment_ids', string='设备维保标准')
eq_maintenance_id =fields.Many2one('equipment.maintenance.standards', string='设备保养标准', domain="[('maintenance_type','=','保养')]") eq_maintenance_id =fields.Many2one('equipment.maintenance.standards', string='设备保养标准', domain="[('maintenance_type','=','保养')]")
overhaul_date = fields.Date(string='下次预防检修') overhaul_date = fields.Date(string='下次预防检修')
overhaul_period = fields.Integer(string='预防检修频次') overhaul_period = fields.Integer(string='预防检修频次')
@@ -41,17 +41,21 @@ class SfMaintenanceEquipment(models.Model):
overhaul_id = fields.Many2one('equipment.maintenance.standards', string='设备检修标准', domain="[('maintenance_type','=','检修')]") overhaul_id = fields.Many2one('equipment.maintenance.standards', string='设备检修标准', domain="[('maintenance_type','=','检修')]")
# @api.depends('eq_maintenance_id', 'overhaul_id') @api.onchange('eq_maintenance_id', 'overhaul_id')
# def _compute_equipment_maintenance_standards_ids(self): def _compute_equipment_maintenance_standards_ids(self):
# for record in self: for record in self:
# if record.eq_maintenance_id == False: if record.eq_maintenance_id and record.overhaul_id:
# record.equipment_maintenance_standards_ids = [ record.equipment_maintenance_standards_ids = [(6, 0, [record.eq_maintenance_id.id, record.overhaul_id.id])]
# (6, 0, [record.overhaul_id.id]),(3,record.eq_maintenance_id.id,0)] break
# if record.overhaul_id == False: if record.eq_maintenance_id:
# record.equipment_maintenance_standards_ids = [ record.equipment_maintenance_standards_ids = [(6, 0, [record.eq_maintenance_id.id])]
# (6, 0, [record.eq_maintenance_id.id]),(3,record.overhaul_id.id,0)] break
# else: if record.overhaul_id:
# record.equipment_maintenance_standards_ids = [(6, 0, [record.eq_maintenance_id.id, record.overhaul_id.id])] record.equipment_maintenance_standards_ids = [(6, 0, [record.overhaul_id.id])]
break
else:
record.equipment_maintenance_standards_ids = False
MTcode = fields.Char("编码", default=get_no) MTcode = fields.Char("编码", default=get_no)

View File

@@ -9,5 +9,20 @@ class SfMaintenanceEquipmentCategory(models.Model):
_inherit = 'maintenance.request' _inherit = 'maintenance.request'
_description = '维保计划' _description = '维保计划'
sf_maintenance_type = fields.Selection([('保养', '保养'), ('检修', '检修')], string='维保类别', default='保养')
equipment_maintenance_id = fields.Many2one('equipment.maintenance.standards', string='设备维保标准',
domain="[('maintenance_type','=',sf_maintenance_type)]")
@api.onchange('sf_maintenance_type')
def _compute_equipment_maintenance_request_id(self):
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(_("设备没有配置维保标准,请配置后再保存"))

View File

@@ -1,20 +1,53 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<odoo> <odoo>
<!-- equiment.request : actions --> <!-- equiment.request : actions -->
<!-- <record id="hr_equipment_request_action" model="ir.actions.act_window">-->
<!-- <field name="name">维保计划</field>--> <record model="ir.ui.view" id="sf_hr_equipment_request_view_form">
<!-- <field name="res_model">maintenance.request</field>--> <field name="name">sf.equipment.request.form</field>
<!-- <field name="view_mode">kanban,tree,form,pivot,graph,calendar</field>--> <field name="model">maintenance.request</field>
<!-- <field name="view_id" ref="maintenance.hr_equipment_request_view_kanban"/>--> <field name="inherit_id" ref="maintenance.hr_equipment_request_view_form"/>
<!-- <field name="context">{'default_user_id': uid}</field>--> <field name="arch" type="xml">
<!-- <field name="help" type="html">--> <xpath expr="//field[@name='maintenance_type']" position="replace">
<!-- <p class="o_view_nocontent_smiling_face">--> <field name="sf_maintenance_type" widget="radio"/>
<!-- Add a new maintenance request--> <field name="equipment_maintenance_id"/>
<!-- </p><p>-->
<!-- Follow the process of the request and communicate with the collaborator.--> </xpath>
<!-- </p>--> <!-- <sheet>-->
<!-- </field>-->
<!-- </record>--> <!-- <notebook>-->
<!-- <page string="维保标准">-->
<!-- <field name="equipment_maintenance_id" widget="many2one"/>-->
<!-- </page>-->
<!-- </notebook>-->
<!-- </sheet>-->
</field>
</record>
<record id="hr_equipment_request_action" model="ir.actions.act_window">
<field name="name">维保计划</field>
<field name="res_model">maintenance.request</field>
<field name="view_mode">kanban,tree,form,pivot,graph,calendar</field>
<field name="view_id" ref="maintenance.hr_equipment_request_view_kanban"/>
<field name="context">{'default_user_id': uid}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Add a new maintenance request
</p><p>
Follow the process of the request and communicate with the collaborator.
</p>
</field>
</record>
@@ -22,7 +55,7 @@
id="menu_m_request_form" id="menu_m_request_form"
name="维保计划" name="维保计划"
parent="maintenance.menu_m_request" parent="maintenance.menu_m_request"
action="maintenance.hr_equipment_request_action" action="hr_equipment_request_action"
groups="maintenance.group_equipment_manager,base.group_user" groups="maintenance.group_equipment_manager,base.group_user"
sequence="1"/> sequence="1"/>

View File

@@ -18,33 +18,30 @@
<field name="inherit_id" ref="maintenance.hr_equipment_view_form"/> <field name="inherit_id" ref="maintenance.hr_equipment_view_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<data> <data>
<xpath expr="//field[@name='maintenance_team_id']" position="before">
<field name="machine_tool_picture" widget="image" />
</xpath>
<xpath expr="//field[@name='category_id']" position="after"> <xpath expr="//field[@name='category_id']" position="after">
<field name="equipment_type" invisible="1"/> <field name="code" readonly="1"/>
<field name="brand_id" invisible="1"/> <field name="equipment_type"/>
<field name="brand_id"/>
<field name="type_id" attrs="{'invisible': [('equipment_type', '!=', '机床')]}"/> <field name="type_id" attrs="{'invisible': [('equipment_type', '!=', '机床')]}"/>
<field name="machine_tool_category" readonly="1" attrs="{'invisible': [('type_id', '=', False)]}"/> <field name="machine_tool_category" readonly="1" attrs="{'invisible': [('type_id', '=', False)]}" force_save="1"/>
</xpath> </xpath>
<xpath expr="//page[@name='maintenance']" position="after"> <xpath expr="//page[@name='maintenance']" position="after">
<page string="设备参数" name="sf_equipment" attrs="{'invisible': [('type_id', '=', False)]}"> <page string="设备参数" name="sf_equipment" attrs="{'invisible': [('type_id', '=', False)]}">
<group string="参数"> <group string="参数">
<group> <group>
<field name="knife_type" required="1"/>
<field name="workpiece_load" invisible="1"/> <field name="knife_type" />
<field name="lead_screw" invisible="1"/> <field name="workpiece_load"/>
<field name="workbench_L" invisible="1"/> <field name="lead_screw"/>
<field name="workbench_W" invisible="1"/> <field name="workbench_L"/>
<field name="guide_rail" invisible="1"/> <field name="taper"/>
<field name="machine_tool_L" invisible="1"/> <field name="torque"/>
<field name="machine_tool_W" invisible="1"/> <field name="motor_power"/>
<field name="machine_tool_H" invisible="1"/> <field name="tool_quality_max"/>
<field name="feed_speed" invisible="1"/> <field name="tool_long_max"/>
<field name="tool_speed" invisible="1"/>
<field name="distance" invisible="1"/>
<field name="taper" invisible="1"/>
<field name="torque" invisible="1"/>
<field name="motor_power" invisible="1"/>
<field name="tool_quality_max" invisible="1"/>
<field name="tool_long_max" invisible="1"/>
<field name="number_of_knife_library" required="1" options="{'format': false}"/> <field name="number_of_knife_library" required="1" options="{'format': false}"/>
<field name="number_of_axles" widget="radio" options="{'horizontal': true}"/> <field name="number_of_axles" widget="radio" options="{'horizontal': true}"/>
<label for="x_axis" string="加工行程(mm)" <label for="x_axis" string="加工行程(mm)"
@@ -73,6 +70,15 @@
</div> </div>
</group> </group>
<group> <group>
<field name="workbench_W"/>
<field name="guide_rail"/>
<field name="machine_tool_L"/>
<field name="machine_tool_W"/>
<field name="machine_tool_H"/>
<field name="feed_speed"/>
<field name="tool_speed"/>
<field name="distance"/>
<field name="rotate_speed" required="1" string="转速(min)" options="{'format': false}"/> <field name="rotate_speed" required="1" string="转速(min)" options="{'format': false}"/>
<field name="precision" required="1" string="加工精度(mm)"/> <field name="precision" required="1" string="加工精度(mm)"/>
<field name="control_system_id" required="1" options="{'no_create': True}"/> <field name="control_system_id" required="1" options="{'no_create': True}"/>
@@ -112,7 +118,7 @@
<field name="overhaul_duration"/> <field name="overhaul_duration"/>
hours hours
</div> </div>
<field name='equipment_maintenance_standards_ids' widget="many2many_tags" invisible="1"/> <field name='equipment_maintenance_standards_ids' widget="many2many_tags"/>
</xpath> </xpath>
</data> </data>