diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py index 3c2edf74ea3..72f1c0eb342 100644 --- a/addons/product/pricelist.py +++ b/addons/product/pricelist.py @@ -115,11 +115,29 @@ class product_pricelist(osv.osv): if name and operator == '=' and not args: # search on the name of the pricelist and its currency, opposite of name_get(), # Used by the magic context filter in the product search view. - query_args = {'name': name, 'limit': limit} + query_args = {'name': name, 'limit': limit, 'lang': (context or {}).get('lang') or 'en_US'} query = """SELECT p.id - FROM product_pricelist p JOIN - res_currency c ON (p.currency_id = c.id) - WHERE p.name || ' (' || c.name || ')' = %(name)s + FROM (( + SELECT pr.id, pr.name + FROM product_pricelist pr JOIN + res_currency cur ON + (pr.currency_id = cur.id) + WHERE pr.name || ' (' || cur.name || ')' = %(name)s + ) + UNION ( + SELECT tr.res_id as id, tr.value as name + FROM ir_translation tr JOIN + product_pricelist pr ON ( + pr.id = tr.res_id AND + tr.type = 'model' AND + tr.name = 'product.pricelist,name' AND + tr.lang = %(lang)s + ) JOIN + res_currency cur ON + (pr.currency_id = cur.id) + WHERE tr.value || ' (' || cur.name || ')' = %(name)s + ) + ) p ORDER BY p.name""" if limit: query += " LIMIT %(limit)s" diff --git a/addons/product/product.py b/addons/product/product.py index 6b0e22238cd..eed8859bd94 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -527,12 +527,13 @@ class product_product(osv.osv): cr, uid, pricelist, operator='=', context=context, limit=1) pricelist = pricelist_ids[0][0] if pricelist_ids else pricelist - products = self.browse(cr, uid, ids, context=context) - qtys = map(lambda x: (x, quantity, partner), products) - pl = plobj.browse(cr, uid, pricelist, context=context) - price = plobj._price_get_multi(cr,uid, pl, qtys, context=context) - for id in ids: - res[id] = price.get(id, 0.0) + if isinstance(pricelist, (int, long)): + products = self.browse(cr, uid, ids, context=context) + qtys = map(lambda x: (x, quantity, partner), products) + pl = plobj.browse(cr, uid, pricelist, context=context) + price = plobj._price_get_multi(cr,uid, pl, qtys, context=context) + for id in ids: + res[id] = price.get(id, 0.0) for id in ids: res.setdefault(id, 0.0) return res