Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

How to search for several words in products name from sales order?

Naroči se

Get notified when there's activity on this post

This question has been flagged
v7search
8 Odgovori
17182 Prikazi
Avatar
Kitti Upariphutthiphong

Hello,

Is it possible to implement a very flexible (almost like fulltext) search for, i.e., Products in Lines.

The intention of this is for the user to as quickly as possible find the product (during new lines and not using the search view), which they might not even know the exact name, not even order of it, they just know part of the keywords.

For example, given the product name like, "Panel / White Color / 50x40".

I am looking for the way to enhance the product fields (in Order Line), so user can just type "50x40 white" to match the item. It is almost like google search to me.

Many thanks, Kitti U.

4
Avatar
Opusti
Sehrish

You can do it dynamically see this: https://apps.odoo.com/apps/modules/17.0/mh_dynamic_name_search

Avatar
Andreas Brueckl
Best Answer

I think that you are looking for the name_search function. This function is used for the search in many2one fields. This is for example the Product in the Order Line. You can override this function to fulfill you requirements.

As an example look at the name_search function of the Product (product.product).

def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100):
    if not args:
        args = []
    if name:
        ids = self.search(cr, user, [('default_code','=',name)]+ args, limit=limit, context=context)
        if not ids:
            ids = self.search(cr, user, [('ean13','=',name)]+ args, limit=limit, context=context)
        if not ids:
            # Do not merge the 2 next lines into one single search, SQL search performance would be abysmal
            # on a database with thousands of matching products, due to the huge merge+unique needed for the
            # OR operator (and given the fact that the 'name' lookup results come from the ir.translation table
            # Performing a quick memory merge of ids in Python will give much better performance
            ids = set()
            ids.update(self.search(cr, user, args + [('default_code',operator,name)], limit=limit, context=context))
            if not limit or len(ids) < limit:
                # we may underrun the limit because of dupes in the results, that's fine
                ids.update(self.search(cr, user, args + [('name',operator,name)], limit=(limit and (limit-len(ids)) or False) , context=context))
            ids = list(ids)
        if not ids:
            ptrn = re.compile('(\[(.*?)\])')
            res = ptrn.search(name)
            if res:
                ids = self.search(cr, user, [('default_code','=', res.group(2))] + args, limit=limit, context=context)
    else:
        ids = self.search(cr, user, args, limit=limit, context=context)
    result = self.name_get(cr, user, ids, context=context)
    return result
2
Avatar
Opusti
Kitti Upariphutthiphong
Avtor

Hello Andreas. Yes I think this is what I am looking for. Thank you so much!

Joie Hadinata

Where do i put this in odoo online version 16 ?

GRENET Thomas

+1 for Odoo Online. Is there a way to put this code in Odoo Online ?

Avatar
Fabien Pinckaers (fp)
Best Answer

By default, in the search view, if you do 2 searches on the same field (e.g. "Panel" & "White"), OpenERP will apply a OR condition between both. This would result into: Product contain Panel OR product contain "White". So, this will not work for your example.

To do a AND between two criteria of the same field, you can use the advanced search.

For your example, if you are in the Sales Orders or Quotations, you can do this through applying two advanced searches:

Order Lines contains Panel
Order Lines contains White

Do not add conditions within the same advanced search, you must apply two searches.

Note that it will match Panel and White, regardless of the order.

2
Avatar
Opusti
Avatar
filsystem
Best Answer

In search field name from product list (tree) or in field product_id from order line (form) you can use regular sql LIKE expression with wildcard: 'Panel%White%50x40'. You will receive all product with 'Panel' or 'White' or '50x40' in name.

1
Avatar
Opusti
Mahmoud Korayem

What if I need it to search in other fields than the name ?

Michael C

This is BRILLIANT. Thank you.

Avatar
Kitti Upariphutthiphong
Avtor Best Answer

Thanks Fabian for the quick answer. But i think it is not exactly what I am looking for.

The intention of the question is for the user to as quickly as possible find the product (during new lines and not using the search view), which they might not even know the exact name, not even order of it, they just know part of the keywords.

Says, there are huge amount of products. And what they want to find is the one named, "Panel - White Color - 40x40".

I am looking for the way to enhance the product fields (in Order Line), so user can just type "40x40 white" to match the item. It is almost like google search to me.

Sorry if my question is not clear. But this is something many customer wanted (especially, organization with a lot of products)

Thank you, Kitti

0
Avatar
Opusti
Fabien Pinckaers (fp)

please edit your question for clarification instead of adding an answer

Asha

how did you solved this? I am also having same requirement in odoo14 and searching for a solution

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Once installed, how do you use addon web_filter_and_condition?
v7 search
Avatar
Avatar
1
mar. 15
4521
How to allow the use of the child_of operator for users ?
v7 search
Avatar
0
mar. 15
9230
How can I locate the certain SO/PO with the product code/desc?
v7 search
Avatar
Avatar
Avatar
2
mar. 15
6499
How can I change the search for products to treat a space like Google does?
product v7 search
Avatar
0
dec. 23
5617
How to add a scrollbar in product search?
javascript v7 search
Avatar
1
mar. 17
5023
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now