Skip to Content
Menu
This question has been flagged
3 Replies
4108 Views

I wonder to know how I can have both Partnumber and product description in Odoo product and search them

as and example assume I have a disk which its partnumber is:

HDS-2TV-MZ7KM240HAGR005

and its description is:

Samsung SSD SM863, 240GB, SATA 6Gb/s, VNAND, 2.5", 7.0mm, 19nm (3.6 DWPD) w/SED

and I want my users to be able to search by putting "SSD" 

Avatar
Discard
Best Answer

You can improve search view and filter domain like below,

 <field name="name" string="Product" filter_domain="['|',('name','ilike',self),('description','ilike',self)"/>

Avatar
Discard
Author

Thank you Pinakin for your hint

as I'm pretty new to Odoo, I tool you comment and searched around that to come up with the final solution

for those who might get to this question, I'm writing down my steps:

- Actually, my description was in notes and in the "Description for Quotations"

- first I needed to find the name of this field in the model. clicked on help icon on the top right corner then "About" and then clicked on "Activate the developer mode" and its colored turned into blue

- went to Purchase (or where ever the item is) and clicked on the product and open a product and entered in the edit mode and then change to the "Note" tab and put the mouse cursor on the text box. The field name appeared: description_sale. Also, I found the object name (which this field was related to) there: "product.template"

- went to settings (top bar), technical, user interface, views

-serached for "product.template" (when type "product.template" in the search box, the second item searches based on objects)

- in the result page, there were a few views from the type of "Search". I realized that "product.template.search" was the main search view which other product search views were inherited from. (click on it and check "inherited views" and you would see)

- I decided to modify the main search view so all other views would have this option. selected architecture tab and clicked edit

this was the main line for the product search there:

<field name="name" string="Product" filter_domain="['|',('default_code','ilike',self),('name','ilike',self)]"/>

I added the below line

<field name="name" string="Description" filter_domain="['|','|',('default_code','ilike',self),('name','ilike',self),('description_sale','ilike',self)]"/>

(attention to the format of '|' operator. still I have not found a solid document on this, but this link was helpful http://stackoverflow.com/questions/32463585/odoo-searching-multiple-custom-fields-with-one-string)

-save

-refresh page

- put someting in the note->"Description for Quotations"

- go to products page and put something in the search box and select the second row (Description) and it will search both name and description