mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-21 14:12:06 +02:00
19.0 vanilla
This commit is contained in:
parent
d1963a3c3a
commit
2d3ee4855a
7430 changed files with 2687981 additions and 2965473 deletions
|
|
@ -1,28 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo.addons.bus.models.bus_presence import AWAY_TIMER
|
||||
from odoo.addons.bus.models.bus_presence import DISCONNECTION_TIMER
|
||||
from odoo import models
|
||||
|
||||
|
||||
class ResUsers(models.Model):
|
||||
_name = "res.users"
|
||||
_inherit = ["res.users", "bus.listener.mixin"]
|
||||
|
||||
_inherit = "res.users"
|
||||
|
||||
im_status = fields.Char('IM Status', compute='_compute_im_status')
|
||||
|
||||
def _compute_im_status(self):
|
||||
""" Compute the im_status of the users """
|
||||
self.env.cr.execute("""
|
||||
SELECT
|
||||
user_id as id,
|
||||
CASE WHEN age(now() AT TIME ZONE 'UTC', last_poll) > interval %s THEN 'offline'
|
||||
WHEN age(now() AT TIME ZONE 'UTC', last_presence) > interval %s THEN 'away'
|
||||
ELSE 'online'
|
||||
END as status
|
||||
FROM bus_presence
|
||||
WHERE user_id IN %s
|
||||
""", ("%s seconds" % DISCONNECTION_TIMER, "%s seconds" % AWAY_TIMER, tuple(self.ids)))
|
||||
res = dict(((status['id'], status['status']) for status in self.env.cr.dictfetchall()))
|
||||
for user in self:
|
||||
user.im_status = res.get(user.id, 'offline')
|
||||
def _bus_channel(self):
|
||||
return self.partner_id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue