args position in product_product name_search

Bug #1028287 reported by Francesco Apruzzese
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Confirmed
Low
OpenERP R&D Addons Team 2

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)

Tags: product

Related branches

description: updated
Amit Parik (amit-parik)
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Francesco Apruzzese (opencode) wrote :

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

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.