[FIX] maintenance: restrict deletion of teams related to equipment
Currently, an error occurs when the user follows the below steps and tries to run cron "Maintenance: generate preventive maintenance requests" Steps: - Open maintenance > Configuration > Maintenence Teams - Create new team e.g. "ABC" - Go to Equipments and create new equipemnt - Set 1 "Preventive Maintenance Frequency" from maintenance page - Select "ABC" in Maintenance Team >> save it - Delete Maintenence Team "ABC" This commit solves the above issue by restricting the deletion of maintenance teams who are related to equipment. sentry-4467657509 closes odoo/odoo#137943 X-original-commit: 9e4aa20c05999ccd9952480b8fea22b9fb651d74 Signed-off-by: Tiffany Chang (tic) <tic@odoo.com> Signed-off-by: ANSARI MAHAMADASIF (maan) <maan@odoo.com>
This commit is contained in:
@@ -131,7 +131,7 @@ class MaintenanceEquipment(models.Model):
|
||||
maintenance_open_count = fields.Integer(compute='_compute_maintenance_count', string="Current Maintenance", store=True)
|
||||
period = fields.Integer('Days between each preventive maintenance')
|
||||
next_action_date = fields.Date(compute='_compute_next_maintenance', string='Date of the next preventive maintenance', store=True)
|
||||
maintenance_team_id = fields.Many2one('maintenance.team', string='Maintenance Team', check_company=True)
|
||||
maintenance_team_id = fields.Many2one('maintenance.team', string='Maintenance Team', check_company=True, ondelete="restrict")
|
||||
maintenance_duration = fields.Float(help="Maintenance Duration in hours.")
|
||||
|
||||
@api.depends('effective_date', 'period', 'maintenance_ids.request_date', 'maintenance_ids.close_date')
|
||||
|
||||
Reference in New Issue
Block a user