2012-07-24 10:48:48 |
Francesco Apruzzese |
description |
If i try to inherit name_search() function of product_product with super I obtain an error. I want to extend the arguments (args parameter) passed to the function but if I insert a "|" operator the code crash. The problem is in this line:
604 -> ids = self.search(cr, user, [('default_code','=',name)]+ args, limit=limit, context=context)
606 -> ids = self.search(cr, user, [('ean13','=',name)]+ args, limit=limit, context=context)
622 -> ids = self.search(cr, user, [('default_code','=', res.group(2))] + args, limit=limit, context=context)
when the args parameter is built by adding "args" to an array.
This is my code:
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
if name:
args = ['|', ('my_field', operator, name)] + args
print args
res = super(product_product,self).name_search(cr, user, name, args, operator='ilike', context=None, limit=100)
return res
If I print the args parameter at line 604 in product/product.py i read that args is:
[('default_code','=',name),'|', ('my_field', operator, name)]
and this is wrong.
A simple solution is to invert the addends:
604 -> ids = self.search(cr, user, args + [('default_code','=',name)], limit=limit, context=context)
606 -> ids = self.search(cr, user,args + [('ean13','=',name)], limit=limit, context=context)
622 -> ids = self.search(cr, user,args + [('default_code','=', res.group(2))], limit=limit, context=context) |
If i try to inherit name_search() function of product_product with super I obtain an error. I want to extend the arguments (args parameter) passed to the function but if I insert a "|" operator the code crash. The problem is in this line:
604 -> ids = self.search(cr, user, [('default_code','=',name)]+ args, limit=limit, context=context)
606 -> ids = self.search(cr, user, [('ean13','=',name)]+ args, limit=limit, context=context)
622 -> ids = self.search(cr, user, [('default_code','=', res.group(2))] + args, limit=limit, context=context)
when the args parameter is built by adding "args" to an array.
This is my code:
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
if name:
args = ['|', ('my_field', operator, name)] + args
print args
res = super(product_product,self).name_search(cr, user, name, args, operator=operator, context=context, limit=limit)
return res
If I print the args parameter at line 604 in product/product.py i read that args is:
[('default_code','=',name),'|', ('my_field', operator, name)]
and this is wrong.
A simple solution is to invert the addends:
604 -> ids = self.search(cr, user, args + [('default_code','=',name)], limit=limit, context=context)
606 -> ids = self.search(cr, user,args + [('ean13','=',name)], limit=limit, context=context)
622 -> ids = self.search(cr, user,args + [('default_code','=', res.group(2))], limit=limit, context=context) |
|