我想知道如何继续在销售报价中按条形码(ean 13)搜索产品。就像这里的图片,我只有产品名称和产品内部参考。
我尝试像这样覆盖模型 product.product :
# -*- 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)])