Domain takes "AND" by default. On Fri, Sep 28, 2012 at 2:08 PM, Cédric Krier <[email protected]> wrote: > On 27/09/12 15:12 -0700, Tristian Paul wrote: >> Hi I've been struggling to create the following domain >> >> I want all the records of a model for which one or both of two fields have >> > the same value >> >> and where created on a list of given days, each day starts at 0:0:0 and >> > ends at 23:59:59 >> >> >> For example in a person database containing the following model >> >> class Person(ModelSQL): >> # implicit create date >> firstname = Char('Firstname') >> lastname = Char('Lastname') >> >> Here's the current domain that I have: >> given that >> >> dates = [date(2012, 9, 10, date(2012, 9, 2), date(2012,9,3) ] >> name = 'Smith' >> dom = [ >> ['OR', >> [('lastname', '=', name)], >> [('firstname', '=', name)] >> ], >> ['OR', >> [ [ > > Here it becomes a 'AND' because list without 'AND' or 'OR' are by > default 'AND' so you must append your list comprehension to the list > with ['OR']. > >> (CD, '>=', dt(date(d.year, d.month, d.day), time(0, >> 0, 0))), >> (CD, '<', dt(date(d.year, d.month, d.day), time(23, >> 59, 59))), >> ] for d in dates ] >> ] >> ] > > > > -- > Cédric Krier > > B2CK SPRL > Rue de Rotterdam, 4 > 4000 Liège > Belgium > Tel: +32 472 54 46 59 > Email/Jabber: [email protected] > Website: http://www.b2ck.com/
-- Mohit Sarla -- -- [email protected] mailing list
