Hi, I am trying to pass the active id to a popup window so that in my function I can access the actual state of the caller object.
For that, I'm doing the following. In XML view:
<page string="Opinions">
<field name="opinion_ids" context="{'generic_request_id': active_id}" >
<tree delete="false">
<field name="request_state" />
<field name="opinion_request_date" />
<field name="requestor" />
(...)
In python I have:
_defaults={
'state': 'requested',
'opinion_request_date': lambda *a: datetime.date.today().strftime('%Y-%m-%d'),
'request_state': lambda self, cr, uid, context: self._get_request_state(cr, uid, context=context), #store the state of the request when opinion was asked
(...)
}
(...)
def _get_request_state(self, cr, uid, context=None):
ids = context.get('generic_request_id', False)
#import pdb; pdb.set_trace()
return self.pool.get('generic.request').browse(cr, uid, ids, context).state
In pdb I realize that "ids" is False because there is no generic_request_id variable in context...
(Pdb) p ids
False
(Pdb) p context
{'lang': 'en_US', 'no_store_function': True, 'tz': False, 'uid': 1}
Anyone knows a way to do this?