'Update the fold_state of the given session. In order to syncronize web browser
tabs, the change will be broadcast to himself (the current user channel).
Note: the user need to be logged
:param state : the new status of the session for the current user.'

@api.model
def channel_fold(self, uuid, state=None):

    domain = [('partner_id', '=', self.env.user.partner_id.id), ('channel_id.uuid', '=', uuid)]
    for session_state in self.env['mail.channel.partner'].search(domain):
        if (not state):
            state = session_state.fold_state
            if (session_state.fold_state == 'open'):
                state = 'folded'
            else:
                state = 'open'
        session_state.write({'fold_state': state, 'is_minimized': bool((state != 'closed'))})
        self.env['bus.bus'].sendone((self._cr.dbname, 'res.partner', self.env.user.partner_id.id), session_state.channel_id.channel_info()[0])
