Skip to Content
Menu
This question has been flagged
2 Replies
1898 Views

code python:

def default_domain_users(self):

at=[]

userx = self.env.user.login

if userx == "bendjeddou.o":

ids_biens=self.env['gmat.journaleline'].search([('exp_P','=',0),('rapJor_ids','=',self.id)])

for item in ids_biens:

at.append(item.bien_id.id)

return at

else:

ids_biens=self.env['gmat.journaleline'].search([('rapJor_ids','=',self.id)])

for item in ids_biens:

at.append(item.bien_id.id)

return at

user_filter = fields.Many2one('gmat.nbien',domain=[('id','in',default_domain_users)])

message ERROR:

Traceback (most recent call last):

File "/opt/odoo/openerp/http.py", line 544, in _handle_exception

return super(JsonRequest, self)._handle_exception(exception)

File "/opt/odoo/openerp/http.py", line 595, in dispatch

return self._json_response(result)

File "/opt/odoo/openerp/http.py", line 533, in _json_response

body = simplejson.dumps(response)

File "/usr/local/lib/python2.7/dist-packages/simplejson/__init__.py", line 366, in dumps

return _default_encoder.encode(obj)

File "/usr/local/lib/python2.7/dist-packages/simplejson/encoder.py", line 269, in encode

chunks = self.iterencode(o, _one_shot=True)

File "/usr/local/lib/python2.7/dist-packages/simplejson/encoder.py", line 348, in iterencode

return _iterencode(o, 0)

File "/usr/local/lib/python2.7/dist-packages/simplejson/encoder.py", line 246, in default

raise TypeError(repr(o) + " is not JSON serializable")

TypeError: <function default_domain_users at 0x7fcfb6570aa0> is not JSON serializable

Avatar
Discard
Author Best Answer

i try working by domain exemple in my function i write :

ids_biens=self.env['gmat.journaleline'].search([('rapJor_ids','=',self.id)])

for item in ids_biens:

at.append(item.bien_id.id)

return [('id','in',at)]

user_filter = fields.Many2one('gmat.nbien',domain=default_domain_users

), but allways display self.id = false
what i do?

Avatar
Discard
Best Answer

hi,

Issue with function return either [ ] empty list or if some value you need to set domain something like [('id','in',at)].

Avatar
Discard
Related Posts Replies Views Activity
1
Aug 23
12546
1
Aug 23
11040
1
Jul 23
7222
4
Apr 23
8676
2
Feb 23
17590