Skip to content
Snippets Groups Projects
Commit a693b368 authored by Lucas Lefèvre's avatar Lucas Lefèvre
Browse files

[FIX] fleet: Assign internal user as driver


With a user with only Fleet Administrator rights.
Assign an internal user as the driver of a vehicle (other than the
current user) => access error, you cannot write on model `res.user`.

Writing on a partner linked to an internal user requires write access to
this user.

closes odoo/odoo#47505

Signed-off-by: default avatarYannick Tivisse (yti) <yti@odoo.com>
parent 026447e7
No related branches found
No related tags found
No related merge requests found
......@@ -208,7 +208,7 @@ class FleetVehicle(models.Model):
res.create_driver_history(vals['driver_id'])
if 'future_driver_id' in vals and vals['future_driver_id']:
future_driver = self.env['res.partner'].browse(vals['future_driver_id'])
future_driver.write({'plan_to_change_car': True})
future_driver.sudo().write({'plan_to_change_car': True})
return res
def write(self, vals):
......@@ -218,7 +218,7 @@ class FleetVehicle(models.Model):
if 'future_driver_id' in vals and vals['future_driver_id']:
future_driver = self.env['res.partner'].browse(vals['future_driver_id'])
future_driver.write({'plan_to_change_car': True})
future_driver.sudo().write({'plan_to_change_car': True})
res = super(FleetVehicle, self).write(vals)
if 'active' in vals and not vals['active']:
......@@ -248,7 +248,7 @@ class FleetVehicle(models.Model):
vehicles._close_driver_history()
for vehicle in self:
vehicle.future_driver_id.write({'plan_to_change_car': False})
vehicle.future_driver_id.sudo().write({'plan_to_change_car': False})
vehicle.driver_id = vehicle.future_driver_id
vehicle.future_driver_id = False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment