[imp] Improve the price margin calculation and name_search for variant.

bzr revid: amb@tinyerp.com-20131011123024-utkshw2tr1z8y8ah
This commit is contained in:
Amit Bhavsar (Open ERP) 2013-10-11 18:00:24 +05:30
parent 1ca616ddfd
commit 7384ea8108
1 changed files with 4 additions and 4 deletions

View File

@ -486,7 +486,7 @@ class product_product(osv.osv):
uom.id, product.list_price, context['uom'])
else:
res[product.id] = product.list_price
res[product.id] = (res[product.id] or 0.0) * (product.price_margin or 1.0) + product.price_extra
res[product.id] = (res[product.id] + ((res[product.id] * (product.price_margin)) / 100)) + product.price_extra
return res
def _get_partner_code_name(self, cr, uid, ids, product, partner_id, context=None):
@ -558,7 +558,7 @@ class product_product(osv.osv):
_defaults = {
'active': lambda *a: 1,
'price_extra': lambda *a: 0.0,
'price_margin': lambda *a: 1.0,
'price_margin': lambda *a: 0.0,
'color': 0,
}
@ -686,7 +686,7 @@ class product_product(osv.osv):
# OR operator (and given the fact that the 'name' lookup results come from the ir.translation table
# Performing a quick memory merge of ids in Python will give much better performance
ids = set()
ids.update(self.search(cr, user, args + [('default_code',operator,name)], limit=limit, context=context))
ids.update(self.search(cr, user, args + ['|',('default_code',operator,name),('variants',operator,name)], limit=limit, context=context))
if not limit or len(ids) < limit:
# we may underrun the limit because of dupes in the results, that's fine
ids.update(self.search(cr, user, args + [('name',operator,name)], limit=(limit and (limit-len(ids)) or False) , context=context))
@ -718,7 +718,7 @@ class product_product(osv.osv):
for product in self.browse(cr, uid, ids, context=context):
res[product.id] = product[ptype] or 0.0
if ptype == 'list_price':
res[product.id] = (res[product.id] * (product.price_margin or 1.0)) + \
res[product.id] = (res[product.id] + ((res[product.id] * (product.price_margin)) / 100)) + \
product.price_extra
if 'uom' in context:
uom = product.uom_id or product.uos_id