From 2d470a423f02b5b19fd1b6cb44c4c1ac6aaad347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Lef=C3=A8vre?= Date: Wed, 5 Feb 2020 10:01:24 +0000 Subject: [PATCH] [IMP] fleet: Close driver history on driver change Purpose ======= If you set a future driver and click on "apply change", a new assignation log is automatically created for the new driver. But the end date of the former assignation isn't populate. Specifications ============== Set the date "end date" for the former driver with the "start date" of the new driver. closes odoo/odoo#44635 Signed-off-by: Yannick Tivisse (yti) --- addons/fleet/models/fleet_vehicle.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/fleet/models/fleet_vehicle.py b/addons/fleet/models/fleet_vehicle.py index 1a088fcb392..13b12360555 100644 --- a/addons/fleet/models/fleet_vehicle.py +++ b/addons/fleet/models/fleet_vehicle.py @@ -238,6 +238,7 @@ class FleetVehicle(models.Model): }) def action_accept_driver_change(self): + self._close_driver_history() # Find all the vehicles 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)])