Odoo Help

0

How can i search a product using name or barcode from search bar of product?

By
samba
on 8/25/14, 1:27 AM 3,206 views

From the search bar of product now we can search using name of product, but my need is have to search with name or barcode. we can use advanced search barcode, to search a product using barcode. But i want to use only serch bar not advanced search. As per my knowledge i have to change "name_search" in produc.product. Please provide me that function code. correct me if i am wrong.

Hi Samba, If you want practical ex. then I can give you or give me your code I will correct it.

Emipro Technologies Pvt. Ltd.
on 8/25/14, 7:24 AM

Ex given by Shashank is the first way as I have explain.

Emipro Technologies Pvt. Ltd.
on 8/25/14, 8:36 AM

from openerp.osv import fields, osv import os.path import fnmatch from tools.translate import _ class product_extension(osv.osv): _inherit = "product.product" _columns = { 'ean13': fields.char('Barcode', size=256, help="International Article Number used for product identification."), } def _check_ean_key(self, cr, uid, ids, context=None): return True _constraints = [(_check_ean_key, 'You provided an invalid "EAN13 Barcode" reference. You may use the "Internal Reference" field instead.', ['ean13'])] def name_search(self, cr, uid, name='', args=None, operator='ilike', context=None): if not args: args = [] if name: args += ['|',('name',operator,name),('ean13',operator,name)] dept_ids = self.search(cr, uid, args, context=context) else: dept_ids = self.search(cr, uid, args, context=context) return self.name_get(cr, uid, dept_ids, context=context)

samba
on 8/25/14, 11:07 AM
1

Hi Samba,

There is two way to achive your objective.

1) Keep product name and add barcode into search bar.

For this you have to just add "ean13" field into search view by inheriting product search view.

2) Replace product name with Barcode into search bar.

For this you have to just replace "name" field with "ean13" field into search view by inheriting product search view.

1
shashank verma
On 8/25/14, 8:30 AM

Hello Samba,

U need to add your field name inside search view in .xml file.Lets consider an example:

        <record id="view_my_product_filter" model="ir.ui.view">
            <field name="name">my.object.search</field>
            <field name="model">my.object</field>
            <field name="arch" type="xml">
                <search string="Search Me">
                
                    <field name="name" string="Product Name" />
                    <field name="my_barcode" string="Barcode"/>
               </search>
            </field>
        </record>    

        
        

So when you type smething on search bar ,a drop down  list will appear. Select from the drop down list(product name,barcode) and hit enter.        

Visit below  link for better understanding

http://postimg.org/image/w3qqj5wh1/

0

If you give in Internal reference to your product like Food_bread_1KG you can find it when you search in the search bar... you can type bread or 1KG or food and you will find it. 

but for barcode i dont know :)

0
ahmad
On 8/25/14, 5:16 AM

you have to use advanced search, choose EAN13 barcode. then you can put the barcode.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)

Stats

Asked: 8/25/14, 1:27 AM
Seen: 3206 times
Last updated: 3/28/17, 4:13 AM