[FIX] product price was wrong when margin is not set
authorOlivier Laurent <olt@tinyerp.com>
Mon, 27 Jul 2009 09:10:20 +0000 (11:10 +0200)
committerOlivier Laurent <olt@tinyerp.com>
Mon, 27 Jul 2009 09:10:20 +0000 (11:10 +0200)
  If margin is not set, it equals False. Multiplting a number by False set this number to 0

bzr revid: olt@tinyerp.com-20090727091020-vd8vmj70yxom3v30

addons/product/product.py

index 1937912..1220176 100644 (file)
@@ -383,7 +383,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 + product.price_extra
+            res[product.id] =  (res[product.id] or 0.0) * (product.price_margin or 1.0) + product.price_extra
         return res
 
     def _get_partner_code_name(self, cr, uid, ids, product_id, partner_id, context={}):
@@ -518,7 +518,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) + \
+                res[product.id] = (res[product.id] * (product.price_margin or 1.0)) + \
                         product.price_extra
             if 'uom' in context:
                 uom = product.uos_id or product.uom_id