From 255eb5cd90d1a0af77168cb6c3f1e0bdfb805ba9 Mon Sep 17 00:00:00 2001 From: Mahamadasif Ansari Date: Mon, 18 Sep 2023 16:49:17 +0530 Subject: [PATCH] [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) Signed-off-by: ANSARI MAHAMADASIF (maan) --- addons/maintenance/models/maintenance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/maintenance/models/maintenance.py b/addons/maintenance/models/maintenance.py index c4ad06339ac..32b25c36d0a 100644 --- a/addons/maintenance/models/maintenance.py +++ b/addons/maintenance/models/maintenance.py @@ -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')