コンテンツへスキップ
メニュー
この質問にフラグが付けられました
3 返信
6844 ビュー

Hello,

I am trying to figure out how to search a product by combining 2 attributes. 

I have a product A which has 2 variant types : brand (brandX and brandY) and color (black, white and blue) : total 6 variants.

I want to be able to search for product A with brandX AND color Black but instead Odoo is searching for product A with brandX OR color black. 

I tried adding +, AND, &, space, brand:brandX, and few other things but it's not working. Any way to achieve this?

Thanks!



アバター
破棄
最善の回答

Search terms you apply to the same search (usually the same field) are combined with OR.

Example: Enter large, apply to Attributes.  Enter red, apply to Attributes.



Search terms you apply to different searches (usually different fields) are combined with AND.

Example: Enter large, apply to Attributes.  Enter stock, apply to Location.

 

To force Odoo to "OR" your different search terms together:

Use ADD A CONDITION under the Filters Menu beneath the search bar:



This results in two search terms on different fields being applied with OR:



To force Odoo to "AND" your same search terms together

Create two Custom Filters under Filters Menu beneath the search bar.  (Product Attributes is the field to search in your case);

This results in two search terms on the same field being applied with AND:

 

Note: Although the screenshots are from the Enterprise edition of version 9, this is how it works on the Community edition of version 8 and 9.

アバター
破棄
著作者

It works when I use the Custom filter options, thanks.

最善の回答

I know my answer is late but it can be help

if you want to search by part of words , you can use % symbol between your inputs

e.g : search for product named "Iphone gold" , inter  : iph%go  in the search 

アバター
破棄
最善の回答

Tom,
if i am not wrong with your requirement then you can simply use this domain:

[('<product_field>', '=' product_id),('<brand_field>','=', 'brandX'),('<color_field>','=','black')]

you can use it in your search method and should resolve it!    

Hope it helps!

アバター
破棄
著作者

Thanks but this is complicated to use for my staff... I was looking for something more intuitive.

関連投稿 返信 ビュー 活動
1
2月 22
2617
1
7月 25
390
1
2月 25
1210
0
9月 23
2151
2
6月 23
3910