From 10268bbed678cc9bfa8a4fed6ae34a163e9b7723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 7 Aug 2012 12:53:48 +0200 Subject: [PATCH] unit_price and quantity could be None during on_change calls issue2740 (transplanted from 106b5697c8ac029aaff864f8cf556fa91ab2ef00) --- purchase.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/purchase.py b/purchase.py index 0e96a11e66..2e9d1462b5 100644 --- a/purchase.py +++ b/purchase.py @@ -353,8 +353,8 @@ class Purchase(Workflow, ModelSQL, ModelView): with Transaction().set_context(context): tax_list = tax_obj.compute(line.get('taxes', []), - line.get('unit_price', Decimal('0.0')), - line.get('quantity', 0.0)) + line.get('unit_price') or Decimal('0.0'), + line.get('quantity') or 0.0) for tax in tax_list: key, val = invoice_obj._compute_tax(tax, 'in_invoice') if not key in taxes: @@ -1060,7 +1060,7 @@ class PurchaseLine(ModelSQL, ModelView): context2['purchase_date'] = vals['_parent_purchase.purchase_date'] with Transaction().set_context(context2): res['unit_price'] = product_obj.get_purchase_price([product.id], - vals.get('quantity', 0))[product.id] + vals.get('quantity') or 0)[product.id] if res['unit_price']: res['unit_price'] = res['unit_price'].quantize( Decimal(1) / 10 ** self.unit_price.digits[1]) @@ -1131,7 +1131,7 @@ class PurchaseLine(ModelSQL, ModelView): context['uom'] = vals['unit'] with Transaction().set_context(context): res['unit_price'] = product_obj.get_purchase_price( - [vals['product']], vals.get('quantity', 0) + [vals['product']], vals.get('quantity') or 0 )[vals['product']] if res['unit_price']: res['unit_price'] = res['unit_price'].quantize(