I'm working with Odoo 10, and I'm trying to modify the fleet module like the next image
We need the field "Conductor" (Driver) be unique, I mean, a vehicle only can have assigned one driver and the driver can't have more than one vehicle assigned.
I used this code:
@api.constrains('driver_id')
def _check_driver(self):
for record in self:
if record.driver_id in self:
raise ValidationError("Driver already has a vehicle assigned")
but that code doesn't work. How can I solve it?