'This function write an entry in the openchatter whenever we change important information
on the vehicle like the model, the drive, the state of the vehicle or its license plate'

@api.multi
def write(self, vals):

    for vehicle in self:
        changes = []
        if (('model_id' in vals) and (vehicle.model_id.id != vals['model_id'])):
            value = self.env['fleet.vehicle.model'].browse(vals['model_id']).name
            oldmodel = (vehicle.model_id.name or _('None'))
            changes.append((_("Model:    from    '%s'    to    '%s'") % (oldmodel, value)))
        if (('driver_id' in vals) and (vehicle.driver_id.id != vals['driver_id'])):
            value = self.env['res.partner'].browse(vals['driver_id']).name
            olddriver = (vehicle.driver_id.name or _('None'))
            changes.append((_("Driver:    from    '%s'    to    '%s'") % (olddriver, value)))
        if (('state_id' in vals) and (vehicle.state_id.id != vals['state_id'])):
            value = self.env['fleet.vehicle.state'].browse(vals['state_id']).name
            oldstate = (vehicle.state_id.name or _('None'))
            changes.append((_("State:    from    '%s'    to    '%s'") % (oldstate, value)))
        if (('license_plate' in vals) and (vehicle.license_plate != vals['license_plate'])):
            old_license_plate = (vehicle.license_plate or _('None'))
            changes.append((_("License    Plate:    from    '%s'    to    '%s'") % (old_license_plate, vals['license_plate'])))
        if (len(changes) > 0):
            self.message_post(body=',    '.join(changes))
        return super(FleetVehicle, self).write(vals)
