Domain question

I am trying to write a domain for model A, based on model A’s one2many relation with model B. Model B has both (1) a boolean attribute current, and (2) a many2one relation with employee. The domain should include instances of A where there exists a related model B that is both current, and related to the Transaction employee.

I have it partially working (as to the employee), and am asking how to add the current test.

The partially working code is:
[(‘modelBs.employee’, ‘=’, Transaction().context.get(‘employee’)]

Hi Jonathan,

In this case you should use the where operator so the one2many records will match both conditions.

You can write the domain as follows:

[('modelBs', 'where', [
    ('current', '=', True), 
    ('employee', '=', Transaction().context.get('employee')])]

Hope it helps!

1 Like

Thank you so much for your advice!

When I try to use where, I’m getting a maximum recursion depth error. Do you know why that would be?

This partial version, without where works (I’m now using real model names, instead of ModelA/B):
[('resources.employee', '=', current_employee)]

But this gives maximum recursion:
[('resources', 'where', [('service.template.current_team_member', '=', True)])]

FYI, I’m using using old Tryton 3.4.

where operator has been added in 4.0.

Thanks for the response. Yet another reason I should upgrade.