Received: by 10.14.220.131 with SMTP id o3mr8279848eep.6.1348832010084; Fri, 28 Sep 2012 04:33:30 -0700 (PDT) X-BeenThere: tryton@googlegroups.com Received: by 10.14.213.71 with SMTP id z47ls2168771eeo.6.gmail; Fri, 28 Sep 2012 04:33:26 -0700 (PDT) Received: by 10.14.178.199 with SMTP id f47mr8281826eem.3.1348832006828; Fri, 28 Sep 2012 04:33:26 -0700 (PDT) Received: by 10.14.178.199 with SMTP id f47mr8281825eem.3.1348832006818; Fri, 28 Sep 2012 04:33:26 -0700 (PDT) Return-Path: Received: from mail-ee0-f45.google.com (mail-ee0-f45.google.com [74.125.83.45]) by gmr-mx.google.com with ESMTPS id v3si11736798eep.1.2012.09.28.04.33.26 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 28 Sep 2012 04:33:26 -0700 (PDT) Received-SPF: pass (google.com: domain of mohitsa...@gmail.com designates 74.125.83.45 as permitted sender) client-ip=74.125.83.45; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of mohitsa...@gmail.com designates 74.125.83.45 as permitted sender) smtp.mail=mohitsa...@gmail.com; dkim=pass header...@gmail.com Received: by mail-ee0-f45.google.com with SMTP id b47so1498815eek.32 for ; Fri, 28 Sep 2012 04:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=6djxSozXqSveGZ8WPlUzXJjal/pEXNiieM8l0nqnl7g=; b=r1XXzMMqCvuf2s5MVsOKeLSnFRDNstAfUAqmdeUnUDs5HOMalSDbcMRpXRZCXlvLXV tNfJKpjFzVNeK8/9vSf92yhu7hPFkHdAbDISmW88W+dAU7ZlFU9vv5KnxUyrVRKNga+9 EUbjqP+1zr6yJUAOqYVa/oZ1ILSLh9U/0iZ4wXTKyB85xsta0ofgYcSpGBtaPWyyBi/1 Cd14eHVlddanFiFJzEWvJreNPWwJ3kHbcEXu3gSGXgQMRHE+Jgea4zWg96sAdJwtBBxv QllkOqpRZhgm9iTZw/PEquKe2iybRTv+OfQOo7snQRkUB6+xn6xhHCs7zel1jkqWOuyJ FD7Q== MIME-Version: 1.0 Received: by 10.14.184.134 with SMTP id s6mr9426304eem.46.1348832006696; Fri, 28 Sep 2012 04:33:26 -0700 (PDT) Received: by 10.14.211.4 with HTTP; Fri, 28 Sep 2012 04:33:26 -0700 (PDT) In-Reply-To: References: <66020cdc-b2d2-4bee-afab-98a9038ddfdd@googlegroups.com> <20120928083804.GB10...@tetsuo.ced.homedns.org> Date: Fri, 28 Sep 2012 17:03:26 +0530 Message-ID: Subject: Re: [tryton] Creating this search doman From: mohit sarla To: tryton@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable dom =3D [ ['OR', [('lastname', '=3D', name)], [('firstname', '=3D', name)] ], this is write for all the records of a model for which one or both of two fields have the same value On Fri, Sep 28, 2012 at 4:37 PM, mohit sarla wrote: > Domain takes "AND" by default. > > On Fri, Sep 28, 2012 at 2:08 PM, C=E9dric Krier w= rote: >> 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 h= ave >>> > 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 =3D Char('Firstname') >>> lastname =3D Char('Lastname') >>> >>> Here's the current domain that I have: >>> given that >>> >>> dates =3D [date(2012, 9, 10, date(2012, 9, 2), date(2012,9,3) ] >>> name =3D 'Smith' >>> dom =3D [ >>> ['OR', >>> [('lastname', '=3D', name)], >>> [('firstname', '=3D', 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, '>=3D', dt(date(d.year, d.month, d.day), tim= e(0, >>> 0, 0))), >>> (CD, '<', dt(date(d.year, d.month, d.day), time(2= 3, >>> 59, 59))), >>> ] for d in dates ] >>> ] >>> ] >> >> >> >> -- >> C=E9dric Krier >> >> B2CK SPRL >> Rue de Rotterdam, 4 >> 4000 Li=E8ge >> Belgium >> Tel: +32 472 54 46 59 >> Email/Jabber: cedric.kr...@b2ck.com >> Website: http://www.b2ck.com/ > > > > -- > Mohit Sarla --=20 Mohit Sarla