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.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
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.
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/
you have to use advanced search, choose EAN13 barcode. then you can put the barcode.
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 :)
Hi Samba, If you want practical ex. then I can give you or give me your code I will correct it.
Ex given by Shashank is the first way as I have explain.
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)