Using Pyson in email template

I am still confused with using of Pyson.

For example I would like to retrieve a field behind a Many2One, for example the email field of the party from a sale, to fill in the recipient field of an email template (I know that I can do this by selecting the field party directly, but I’d like to do it in Pyson to understand the syntax).
I tested
[Eval ('party.email', '')] : it doesn’t return anything
[Eval ('self.party.email', '')] : I have an error: Fault: ‘int’ object has no attribute ‘get’

Thanks for your help

This is because we use EvalEnvironment in place of self. So the relation fields are evaluated with their id. This limits a lot the possibilities so I think we should use directly the record.

Sorry i don’t’ see how make that :frowning:

For me we could just remove the usage of EvalEnvironment.

what I understood:
in file: ir/email.py

[...]
#env['self'] = EvalEnvironment(record, record.__class__)
env['self'] = record
[...]

With this Pyson string:
[Eval ('self.party.email', '')] : I have an error: Fault: “sale.sale,36” has no attribute “get”

Then you can use directly self.party.email without using Eval

Indeed PYSON Eval requires a EvalEnvironment.

I do not think so because it is a PYSON expression.

I guess you must write: [Eval('self._parent_party.email', '')]
This is because the prefix _parent_ is evaluated with a new EvalEnvironment instead of just id.

Yes it works, thanks

Ok, and for example to reach the name field of the account receivable of a party (self.party.account_receivable.name) i must write: Eval('self._parent_party._parent_account_receivable.name', '') ?