I want to know how to proceed for adding in the search a product by barcode (ean 13) in sale quotations. Like the image here, I have only the name of the product and product internal reference.
I try to override the model product.product like this :
# -*- coding: utf-8 -*-
from openerp import models, api
class product_product(models.model):
_inherit = "product.product"
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100):
res = super(product_product, self).name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100)
if operator in ('ilike', 'like', '=', '=like', '=ilike'):
domain = [('ean13', operator, name)]
ids = self.search(cr, user, domain, limit=limit, context=context)
res += self.name_get(cr, user, ids, context=context)
return res
self.search([('ean13', 'ilike', name)])
The
name_get
method changes the default name that appears on the drop_down list.Override the
name_search
method instead, something like this:You just need to add the results of the
ean13
as well to the method: