On 2015-10-15 12:01, Jon Levy wrote:
> When used on a One2Many field, the domain '=' operator evaluates True if at 
> least one of the related objects meets its criterion.  But is it possible 
> to add an additional domain clause that tests whether any objects not only 
> meet the first clause, but also meet the second clause?
> 
> For example, let's say I have a Car model with a 'parts' field that is 
> One2Many on a Part model.  Part has fields (1) 'manufacturer', which is 
> Many2One on the standard Party model, and (2) 'warranty', which is boolean, 
> indicating whether the Part comes with a warranty.  I want to be able to 
> search on Car to find all records that have warrantied parts manufactured 
> by Acme, Inc.
> 
> I can create a function string field for warrantying_manufacturers that 
> displays the names of those manufacturers who have warrantied parts on the 
> car, but how can I write a searcher?
> 
> Let's say I write a searcher that returns:
> [
>     ('parts.manufacturer.party.name',) + tuple(clause[1:]),
>     ('parts.warranty', '=', True)
> ]
> 
> If I then search for 'Acme, Inc.' it will return all of the cars that have 
> both a part manufactured by Acme, and a part under warranty.  But the part 
> under warranty may be a different part, and not the one made by Acme.
> 
> Is there any way to accomplish this?

Not yet but this is the goal of https://bugs.tryton.org/issue4507

Otherwise, you can write it using a SQL query which return the matching
ids that you return like this:

    [('id', 'in', sql_query)]


-- 
Cédric Krier - B2CK SPRL
Email/Jabber: [email protected]
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Reply via email to