Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to given presence of the current user in OpenERP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 293
    Comment on it

    In OpenERP first we create users and then validate to the trigger. Users register then status will not be sent if not necessary. In usres form type is user_presence.

    Use this function show in given below

     def updates(self, user_presence=True):
            presence =[('user_id', '=', self._uid)], limit=1)
            send_notification = True
            values = {
                'last_poll': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
                'status': presence and presence.status or 'offline'
            if not presence:  # create a new presence for the user
                values['status'] = 'online'
                values['user_id'] = self._uid
                if user_presence:
                    values['last_presence'] = time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
                    values['status'] = 'online'
                    threshold = - datetime.timedelta(seconds=AWAY_TIMER)
                    if datetime.datetime.strptime(presence.last_presence, DEFAULT_SERVER_DATETIME_FORMAT) < threshold:
                        values['status'] = 'away'
                send_notification = presence.status != values['status']
                # write only if the last_poll is passed TIMEOUT, or if the status has changed
                delta = datetime.datetime.utcnow() - datetime.datetime.strptime(presence.last_poll, DEFAULT_SERVER_DATETIME_FORMAT)
                if delta > datetime.timedelta(seconds=TIMEOUT) or send_notification:
                    # Hide transaction serialization errors, which can be ignored, the presence update is not essential
                    with tools.mute_logger('openerp.sql_db'):
   # TODO : check if still necessary
            if send_notification: 
                self.env['bus.bus'].sendone((self._cr.dbname, 'bus.presence'), {'id': self._uid, 'im_status': values['status']})
            if random.random() < 0.01:
            return True


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: