Addresses from Many2Many mymodel--party.party in E-Mail template

Hi,
I would like to create an e-mail template for a custom model.
the model hast 2 fields. One field many2One to a party.party and one field Many2Many towards party.party.

In the e-mail template I am offered to add a field for “recipients”. When clicking, it offers me only the many2one field, the created_by, edited_by but not the may2many.

Is there a way to add the Many2many partys as recipients?
Or is there a different approach?

Regards Jakob

Which email template are you talking about?

I am talking about:
Administration → Userinterface-> Actions-> E-Mail templates.

Indeed the selection constraint is based on the relation value of the field.
But for Many2Many the relation is the relation table and not the target so they are not available.
I filled Can not select Many2Many as recipients of email template (#13756) · Issues · Tryton / Tryton · GitLab if someone wants to improve the support.

I saw that there is the possibility to use a PYSON STatement in the char field. I tried with
Eval("self.parents", []), where parents is the m2m field linking party.party. But it seems to return an empty list.
Is it possible that way and i am just having a mistake i the statemet or does that not work at all?

Indeed using a PYSON expression should work.

Do you have a hint for me, how to create that pyson statement, please?
(self.parents,[] ) Does not give me a result, but in Trytond-console I can navigate to the model “member”, that should be the model in “self” and get two party-records with member.parents.

It shoudl be Eval('self', {}).get('parents', [])

Unfortunately that does not give a result. The statement is rewritten to Get(Eval("self", {}), "parents", []) when saving the object.
When I use the template from the member model of the cliental- , it does not pull the values.
I double checked in the Trytond-Console:

>>> env = EvalEnvironment(mem, Member)
>>> mem.parents
(Pool().get('party.party')(4), Pool().get('party.party')(3))
>>> b= Eval('parents',[])
>>> PYSONDecoder(env).decode(PYSONEncoder().encode(b))
[4, 3]

The statement, as far as I understand, should return the list [4, 3].

In case, someone else has that problem.
I read somewhere else in the forum, the statement must return a list of strings containing e-mail addresses. I read as well, that iteration over al list of objects I pyson Is not possible.

I now create a Function Field on_change_with depending on the m2m field, that extracts a char list of

name <email>,

That solution is working.