[IMP] maintenance: restrict deletion of equipment if requests exists

Loosing data about existing requests is not good idea when managing
maintenance. It is better to ensure there are no ongoing requests
and prevent deletion if it is the case.

Closes #18794 .
This commit is contained in:
Akim Juillerat
2018-06-13 12:54:48 +02:00
committed by Thibault Delavallée
parent 4fe0981c33
commit 25d63b97a0
+2 -1
View File
@@ -287,7 +287,8 @@ class MaintenanceRequest(models.Model):
help="Date requested for the maintenance to happen")
owner_user_id = fields.Many2one('res.users', string='Created by User', default=lambda s: s.env.uid)
category_id = fields.Many2one('maintenance.equipment.category', related='equipment_id.category_id', string='Category', store=True, readonly=True)
equipment_id = fields.Many2one('maintenance.equipment', string='Equipment', index=True)
equipment_id = fields.Many2one('maintenance.equipment', string='Equipment',
ondelete='restrict', index=True)
technician_user_id = fields.Many2one('res.users', string='Owner', track_visibility='onchange', oldname='user_id')
stage_id = fields.Many2one('maintenance.stage', string='Stage', ondelete='restrict', track_visibility='onchange',
group_expand='_read_group_stage_ids', default=_default_stage)