From 7edde4310044d495eb7d33a0c79d182b49faeb27 Mon Sep 17 00:00:00 2001 From: "Jurgen (jugj)" Date: Fri, 11 Aug 2023 09:22:50 +0000 Subject: [PATCH] [FIX] fleet: Take into account vehicle type when applying new drivers In this PR we fix the current behavior : When you apply a new driver to a vehicle, all other vehicles having that driver as current driver will have their driver_id set to false, but if we are applying a new driver to a bike, we don't want his car, if he has one to be unassigned from him. task-3463518 closes odoo/odoo#131840 X-original-commit: 7649f45ee45aea152224e4ff0fe9b9430ad3c9f8 Signed-off-by: Sofie Gvaladze (sgv) --- addons/fleet/models/fleet_vehicle.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/fleet/models/fleet_vehicle.py b/addons/fleet/models/fleet_vehicle.py index 5a63b10f5f5..1922d939c61 100644 --- a/addons/fleet/models/fleet_vehicle.py +++ b/addons/fleet/models/fleet_vehicle.py @@ -340,9 +340,9 @@ class FleetVehicle(models.Model): ) def action_accept_driver_change(self): - # Find all the vehicles for which the driver is the future_driver_id + # Find all the vehicles of the same type for which the driver is the future_driver_id # remove their driver_id and close their history using current date - vehicles = self.search([('driver_id', 'in', self.mapped('future_driver_id').ids)]) + vehicles = self.search([('driver_id', 'in', self.mapped('future_driver_id').ids), ('vehicle_type', '=', self.vehicle_type)]) vehicles.write({'driver_id': False}) for vehicle in self: