← Back to team overview

openerp-community team mailing list archive

Re: set context depending on the current record in ir.actions.act_window

 


Raphael Valyi wrote:
> 
> 
> On Thu, Aug 4, 2011 at 7:39 PM, Fabien Pinckaers <fp@xxxxxxxxxxx
> <mailto:fp@xxxxxxxxxxx>> wrote:
> 
> 
>     > off-topic but related: today the following test [('foo_ids',
>     'contains',
>     > 'bar')] works with a name based on the name_search stuff. However,
>     from
>     > my quick tests if I remember properly, it doesn't work with an id such
>     > as [('foo_ids', 'contains', id)]. Any chance when an id is provided it
>     > would then try to match the id? That would be more precise because
>     names
>     > can be duplicated eventually or a name could also be included in some
>     > other larger name. What I propose might however conflicts with
>     searching
>     > a name containing some number. Any specific syntax we could adopt to
>     > have this working? Thoughts?
> 
>     Raphaël,
> 
>     Which type of field ? many2one or one2many ? Contains does not exists, I
>     think you probably mean 'like' ?
> 
> 
> Yeah, sorry, meant "ilike". I was asking for one2many and many2many.
> 
> 
>     For searching on ids, we don't use 'like' but:
>      [('foo_ids', '=', id)]
>      [('foo_ids', 'in', [id,id2])]
>     I don't remember having seen/planned some improvements or changes in
>     that area.
> 
> 
> What I sometimes need is the contrary of "in"
> so in your example  [('foo_ids', 'in', [id,id2])]$
> I want to actually rather test that id is inside the foo_ids collection.

If you do [('foo_ids', 'in', [id,id2])] on a one2many, it checks one for
which an in id foo_ids is in (id, id2). So this is what you expect I guess.

When you do [('foo_ids', '=', id)], I think it also searches for a
one2many containing an id (not sure, to be tested), so this is also what
you expect.

As far as I know, the only limitation is that we can not do a ==. So, I
think this is not possible:
   [('foo_ids', '=', [id,id2])]
But I never had a scenario when I needed that. So, unless we have a real
need, this is not a big issue.


-- 
Fabien Pinckaers
CEO OpenERP
Chaussée de Namur 40
B-1367 Grand-Rosière
Belgium
Phone: +32.81.81.37.00
Fax: +32.81.73.35.01
Web: http://openerp.com


Follow ups

References