So i was writing a pyson statement to fetch party from user but i can’t see any party field in user model. do i have to create it on my own or is there any other way to do that ?
Regards
So i was writing a pyson statement to fetch party from user but i can’t see any party field in user model. do i have to create it on my own or is there any other way to do that ?
Regards
Usually it is common to use the current employee to link user with party. But depending on the usage it could be something else.
i did give it a try using employee it doesent seems to work
[['healthprof.name.name', '=', Get(Eval('user', {}), 'employee.party.name', '')]]
You can not use dotted notation as Get
key. Also using nested call will not work because the evaluation of a Many2One
return the id.
But I would also add that making rule based on same name
is not very strong. It is better to use id
(too bad that heathprof.name
has not a better naming).
So if you need to have the party of the employee in the evaluation context (I deduct that it is for a record rule), you must add it to the context like it is done in modules/company/ir.py
to add the employee
.
Thanks for the reply ced
Do you mean like this ?
@classmethod
def _get_context(cls):
pool = Pool()
User = pool.get('res.user')
Employee = pool.get('company.employee')
context = super()._get_context()
# Use root to avoid infinite loop when accessing user attributes
with Transaction().set_user(0):
user = User(Transaction().user)
if user.employee:
with Transaction().set_context(
_check_access=False, _datetime=None):
context['employee'] = EvalEnvironment(
Employee(user.employee.id), Employee)
return context
an example would be greatly appreciated if this is wrong