Creating this search doman

36 views
Skip to first unread message

Tristian Paul

unread,
Sep 27, 2012, 6:12:33 PM9/27/12
to try...@googlegroups.com
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',
                  [ [
                      (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 ]
              ]
      ]
       
Any help is really appreciated.

Jean Cavallo

unread,
Sep 28, 2012, 3:35:52 AM9/28/12
to try...@googlegroups.com
Here's the current domain that I have:


What is the problem with this domain ? (error, does not work as intended...)

Jean 

Cédric Krier

unread,
Sep 28, 2012, 4:38:04 AM9/28/12
to try...@googlegroups.com
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: cedric...@b2ck.com
Website: http://www.b2ck.com/

mohit sarla

unread,
Sep 28, 2012, 7:07:08 AM9/28/12
to try...@googlegroups.com
Domain takes "AND" by default.
--
Mohit Sarla

mohit sarla

unread,
Sep 28, 2012, 7:33:26 AM9/28/12
to try...@googlegroups.com
dom = [
['OR',
[('lastname', '=', name)],
[('firstname', '=', name)]
],

this is write for all the records of a model for which one or both of
two fields have
the same value
--
Mohit Sarla
Reply all
Reply to author
Forward
0 new messages