Using PYSON expression to choose the email template recipient

Hi All,

On a custom module we have a Many2one to model called agent.
We want to have an email template that sends the email to the agent when set but fallback to the customer when not set. So we set the following expression:

If(Eval('self', {}).get('agent'), [Eval('self', {}).get('agent')], [Eval('self', {}).get('party']))

But this expression does not work.

After debugging a little i’ve just found that the expression just returns the id of the model. As this is an integer field the system is unable to get the email nor the name of the party.

Am I doing something wrong?

The PYSON expression must return an email address string.
So it should be something like:

If(Eval('self', {}).get('agent'), [Eval('self', {}).get('')], [Eval('self', {}).get('']))

This is because we use EvalEnvironment for self.

Thanks for the tip.

But then we can not show the “NAME” of the party like we have for other fields.

So if we want it the only option is to use a functional field which return the proper record to be used as recipient (without PYSON).

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