Understanding OpenERP Domain Filter?

后端 未结 2 1904
不思量自难忘°
不思量自难忘° 2020-12-30 13:26

I would like to ask you if you could please explain the anatomy of the Openerp domain filters. I have to use it my project. Please explain the description of the following d

2条回答
  •  礼貌的吻别
    2020-12-30 14:11

    The '|' is an OR that gets applied to the next comparison. The (..., '=', False) gets converted into an IS NULL so the SQL for this would be

    WHERE order_id.user_id = x OR order_id.user_id is NULL
    

    The default is AND which is why you don't see ('&', ('field1', '=' ,1), ('field2' ,'=', 2) everywhere.

    Note that another useful one is ('field1', '!=', False) which gets converted to WHERE field1 IS NOT NULL

    There isn't a lot of great documentation for this and they get quite tricky with multiple operators as you have to work through the tuples in reverse consuming the operators. I find I use complex ones infrequently enough that I just turn on query logging in Postgres and use trial and error observing the generated queries until I get it right.

提交回复
热议问题