'Updates the last_poll and last_presence of the current user
:param inactivity_period: duration in milliseconds'

@api.model
def update(self, inactivity_period):

    presence = self.search([('user_id', '=', self._uid)], limit=1)
    last_presence = (datetime.datetime.now() - datetime.timedelta(milliseconds=inactivity_period))
    values = {'last_poll': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)}
    if (not presence):
        values['user_id'] = self._uid
        values['last_presence'] = last_presence.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
        self.create(values)
    else:
        if (datetime.datetime.strptime(presence.last_presence, DEFAULT_SERVER_DATETIME_FORMAT) < last_presence):
            values['last_presence'] = last_presence.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
        with tools.mute_logger('odoo.sql_db'):
            presence.write(values)
    self.env.cr.commit()
