So I guess you are trying to write a record rule. You can not use the context for record rule because it is not safe. Any user can fill the context with any value.
If you need a specific value available in the evaluation context of record rule, you must override Rule._get_context.
class Rule(metaclass=PoolMeta):
__name__ = 'ir.rule'
@classmethod
def _get_context(cls):
pool = Pool()
User = pool.get('res.user')
Party = pool.get('party.party')
context = super()._get_context()
with Transaction().set_user(0):
user = User(Transaction().user)
if user.employee:
context['party_id'] = EvalEnvironment(
Party(user.employee.party.id), Party)
return context
i wrote this code but still no luck am i doing something wrong ?
an example would be greatly appreciated