[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) <sgv@odoo.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user