Search domain constrain for Many2Many() works like a constant or doesn't work

I can’t understand why this code doesn’t work properly:

    range_zip_codes = [] # List of some ZIP codes that constrains search
    range_zip_codes.append('10001') # Initial constrain

    installers = fields.Many2Many('', 'sale', 'installer', 
        string = 'Installer at the Sale Order', 
        help = 'Select installers in this sale order',
            ('categories.installer', '=', True),
            ('', 'in', Eval('range_zip_codes')) # THIS CONSTRAIN I WANT TO BE FLEXIBLE
        depends=['range_zip_codes', '']

I have a special function that populates self.range_zip_codes list in different conditions with various ZIP codes. I want to constrain the installers filter by codes only within range_zip_codes list.
But the beheivour of the function is very strange:

  ('', 'in', Eval('range_zip_codes')) #— ALWAYS filter out: an empty search tree

in case of

  ('', 'in', range_zip_codes) #— Works like range_zip_codes list is just a constant ['10001']

That is a sample value: range_zip_codes = ['10001', '10475'] or there are many other ZIP codes in this list
But that doesn’t work with Eval().
What I do wrong??


In order to use Eval you should have a function field name ‘range_zip_codes’.
The eval will be evaluated with the content of this field.

If you want this function to be updated when the user changes some field on the record you should consider using an on_change_with so the function field will be reactive to user input.