Technical mailing list archives


New api: Related fields issue

- 09/25/2014 07:54:12
Hi guys!
    def _get_active_session(self):
        """Get open session"""
        session =[
            ('state', 'in', ['running', 'paused'])],
            order='create_date desc', limit=1)
        self.active_session = session
        print 'SESSION', self.active_session
        print 'SESSION PAUSE', self.active_session.pause_request

This code gets the latest session object according to criteria.

To be able to get from views active_session fields I added to the model:

active_session = fields.Many2one('asterisk.dialer.session', compute='_get_active_session')
cancel_request = fields.Boolean('active_session.cancel_request')
pause_request = fields.Boolean('active_session.pause_request')

(I was surpised I cannot do in view: <button name='pause' type='object' string='Pause' attrs="{'invisible': [('active_session.pause_request','!=',True)]}"/>, cannot I chain fields in views?)

But Related field does not work. When there is no active_session self.active_session.pause_request returns False but self.pause_request returns True.
How can it be?