Pyson domain evaluation in Many2Many

Hi,

The following code returns me empty set, I guess it depends on when the Pyson domain is evaluated but I’m not sure.

....
party = fields.Many2One('party.party', 'Party',
        states={
            'invisible': Eval('type') != 'project',
            }, depends=['type'])
parties = fields.Many2Many('project.work-address.relation',
        'project', 'relation', 'Related Parties',
        states={
            'invisible': Eval('type') != 'project',
            },
        domain=[
            ('from_', 'in', Eval('_parent_party.addresses', [])),
            ],
        depends=['type'])
...

I tested the Pyson and it seems to work …

...
>>> t = Eval('_parent_party.addresses')
>>> PYSONDecoder(env).decode(PYSONEncoder().encode(t))
[11, 12]

While the following code works

party = fields.Many2One('party.party', 'Party',
        states={
            'invisible': Eval('type') != 'project',
            }, depends=['type'])
parties = fields.Many2Many('project.work-address.relation',
        'project', 'relation', 'Related Parties',
        states={
            'invisible': Eval('type') != 'project',
            },
        domain=[
            ('from_', 'in', [11, 12]),
            ],
        depends=['type'])
...

A suggestion/idea ?

Thanks a lot.

Maybe missing party on depends, I think you need a function field party_addresses

When? And what do you mean by that?

Having constraint based on _parent_ may be problematic if the record is edited not from the corresponding One2Many.

When I try to choose an item to add it to the Many2Many in the client

Ok, maybe that’s it

@dabada83 : This is what I have done for the moment, but I think that with a Pyson domain it would be more understandable / readable / clean