← Back to team overview

openerp-india team mailing list archive

[Bug 1028287] Re: args position in product_product name_search

 

Plese, it's possibile to fix this bug? I need to release a module to the
community but this bug affect it...

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/1028287

Title:
  args position in product_product name_search

Status in OpenERP Addons (modules):
  Confirmed

Bug 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=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)

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/1028287/+subscriptions


References