pool = Pool()
User = pool.get('res.user')
Employee = pool.get('company.employee')
with Transaction().set_user(0):`
user = User(Transaction().user)
with Transaction().set_context(_check_access=False, _datetime=None):
context['employee'] = EvalEnvironment(Employee(user.employee.party.id), Employee)
but seems like context is not defined . if i am correct the context get automatically get define with 'with statement’
I tested your code and I think that it is defining the context correctly.
Inside the first withTransaction().context is returning {} and in the second one: {'_check_access': False, '_datetime': None}
Is your console not returning the same? Are you expecting to get something different?
Traceback (most recent call last):
File "/usr/local/lib/python37/dist-packages/trytond/wsgipy", line 110, in dispatch_request
selfcheck_request_size(request, max_request_size)
File "/usr/local/lib/python37/dist-packages/trytond/wsgipy", line 90, in check_request_size
if requestuser_id:
File "/werkzeug/utilspy", line 73, in __get__
value = selffunc(obj)
File "/usr/local/lib/python37/dist-packages/trytond/protocols/wrapperspy", line 73, in user_id
context=context)
File "/usr/local/lib/python37/dist-packages/trytond/securitypy", line 85, in check
find = Sessioncheck(user, session)
File "/usr/local/lib/python37/dist-packages/trytond/ir/sessionpy", line 77, in check
domain or [],
File "/usr/local/lib/python37/dist-packages/trytond/model/modelsqlpy", line 1300, in search
domain = Ruledomain_get(cls__name__, mode='read')
File "/usr/local/lib/python37/dist-packages/trytond/ir/rulepy", line 244, in domain_get
clause, clause_global = clsget(model_name, mode=mode)
File "/usr/local/lib/python37/dist-packages/trytond/ir/rulepy", line 209, in get
decoder = PYSONDecoder(cls_get_context())
File "/usr/local/lib/python37/dist-packages/trytond/modules/company/irpy", line 82, in _get_context
return context
NameError: name 'context' is not defined
i was able to sort that out it was related to my code in ir.py in company module. but how can i get the relation in between user and employee for example using context