[IMP] im_livechat: unpin old sessions in the autovacuum cron
This commit is contained in:
@@ -10,4 +10,5 @@ class AutoVacuum(models.AbstractModel):
|
||||
@api.model
|
||||
def power_on(self, *args, **kwargs):
|
||||
self.pool['mail.channel'].remove_empty_livechat_sessions()
|
||||
self.pool['mail.channel.partner'].unpin_old_livechat_sessions()
|
||||
return super(AutoVacuum, self).power_on(*args, **kwargs)
|
||||
|
||||
@@ -1,6 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from openerp import api, fields, models
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
|
||||
class ChannelPartner(models.Model):
|
||||
_inherit = 'mail.channel.partner'
|
||||
|
||||
@api.model
|
||||
def unpin_old_livechat_sessions(self):
|
||||
""" Unpin livechat sessions with no activity for at least one day to
|
||||
clean the operator's interface """
|
||||
self.env.cr.execute("""
|
||||
UPDATE mail_channel_partner
|
||||
SET is_pinned = false
|
||||
WHERE id in (
|
||||
SELECT cp.id FROM mail_channel_partner cp
|
||||
INNER JOIN mail_channel c on c.id = cp.channel_id
|
||||
WHERE c.channel_type = 'livechat' AND cp.is_pinned is true AND
|
||||
cp.write_date < current_timestamp - interval '1 day'
|
||||
)
|
||||
""")
|
||||
|
||||
|
||||
class MailChannel(models.Model):
|
||||
|
||||
Reference in New Issue
Block a user