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 ('', '')] : it doesn’t return anything
[Eval ('', '')] : 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/

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

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

Then you can use directly 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('', '')]
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 ( i must write: Eval('', '') ?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.