[IMP] hr_equipment: add a button cancel on the form to archive the maintenance request

Add also a button Reset Request to set it active true + on the first stage
This commit is contained in:
Yannick Tivisse
2015-08-20 16:29:26 +02:00
parent 93261e07de
commit c28bc7e9bb
3 changed files with 18 additions and 5 deletions
@@ -23,11 +23,6 @@
<field name="sequence" eval="4" />
<field name="fold" eval="True" />
</record>
<record id="stage_5" model="hr.equipment.stage">
<field name="name">Cancelled</field>
<field name="sequence" eval="10" />
<field name="fold" eval="True" />
</record>
<!-- email alias for maintenance requests -->
<record id="mail_alias_equipment" model="mail.alias">
@@ -238,6 +238,21 @@ class HrEquipmentRequest(models.Model):
close_date = fields.Date('Close Date')
kanban_state = fields.Selection([('normal', 'In Progress'), ('blocked', 'Blocked'), ('done', 'Ready for next stage')],
string='Kanban State', required=True, default='normal', track_visibility='onchange')
active = fields.Boolean(default=True, help="Set active to false to hide the maintenance request without deleting it.")
@api.multi
def archive_equipment_request(self):
""" Archive an hr.equipment.request as it was refused """
for equipment_request in self:
equipment_request.write({'active': False})
@api.multi
def reset_equipment_request(self):
""" Reinsert the equipment request into the maintenance pipe"""
for equipment_request in self:
first_stage_obj = self.env['hr.equipment.stage'].search([], order="sequence asc", limit=1)
equipment_request.write({'active': True, 'stage_id': first_stage_obj.id})
@api.onchange('employee_id', 'department_id')
def onchange_department_or_employee_id(self):
@@ -33,6 +33,8 @@
<field name="arch" type="xml">
<form string="Maintenance Request">
<header>
<button string="Cancel" name="archive_equipment_request" type="object" attrs="{'invisible': [('active', '=', False)]}"/>
<button string="Reset Request" name="reset_equipment_request" type="object" attrs="{'invisible': [('active', '=', True)]}"/>
<field name="stage_id" widget="statusbar" clickable="true" readonly="1"/>
</header>
<sheet>
@@ -52,6 +54,7 @@
<field name="category_id" groups="base.group_hr_manager"/>
<field name="request_date" groups="base.group_no_one"/>
<field name="close_date" groups="base.group_no_one"/>
<field name="active" invisible="1"/>
</group>
<group>
<field name="user_id" string="Repair Responsible"/>