[IMP] im_livechat: add gc of empty sessions in the autovacuum cron

This commit is contained in:
Aaron Bohy
2016-06-24 16:34:00 +02:00
parent 1339180ba8
commit 7d64bd5ed2
4 changed files with 16 additions and 17 deletions
@@ -1,20 +1,5 @@
<?xml version="1.0"?>
<odoo>
<data noupdate="1">
<!-- Remove automatically the empty anonoymous sessions -->
<record id="ir_cron_remove_empty_session" model="ir.cron">
<field name="name">[im_livechat] Remove empty anonymous sessions</field>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False"/>
<field name="model">mail.channel</field>
<field name="function">cron_remove_empty_session</field>
<field name="active" eval="True"/>
</record>
</data>
<data>
<!-- Smiley for rating to be displayed in the conversation -->
<record id="mail_shortcode_rating_0" model="mail.shortcode">
+1
View File
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*
import im_livechat_channel
import ir_autovacuum
import mail_channel
import rating
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
class AutoVacuum(models.AbstractModel):
_inherit = 'ir.autovacuum'
@api.model
def power_on(self, *args, **kwargs):
self.pool['mail.channel'].remove_empty_livechat_sessions()
return super(AutoVacuum, self).power_on(*args, **kwargs)
+2 -2
View File
@@ -62,8 +62,8 @@ class MailChannel(models.Model):
return values
@api.model
def cron_remove_empty_session(self):
hours = 1 # never remove empty session created within the last hour
def remove_empty_livechat_sessions(self):
hours = 1 # never remove empty session created within the last hour
self.env.cr.execute("""
SELECT id as id
FROM mail_channel C