'Unpin livechat sessions with no activity for at least one day to
clean the operator\'s interface'

@api.model
def unpin_old_livechat_sessions(self):

    self.env.cr.execute("\n                                                UPDATE    mail_channel_partner\n                                                SET    is_pinned    =    false\n                                                WHERE    id    in    (\n                                                                SELECT    cp.id    FROM    mail_channel_partner    cp\n                                                                INNER    JOIN    mail_channel    c    on    c.id    =    cp.channel_id\n                                                                WHERE    c.channel_type    =    'livechat'    AND    cp.is_pinned    is    true    AND\n                                                                                cp.write_date    <    current_timestamp    -    interval    '1    day'\n                                                )\n                                ")
