unit_price and quantity could be None during on_change calls

issue2740
This commit is contained in:
Cédric Krier committed 2012-08-07 12:53:48 +02:00
1 parent 0c5d4e0be2
commit 0b7c9afc5e
1 file changed
+4 -4
+4 -4
View File
@@ -356,8 +356,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:
@@ -1068,7 +1068,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])
@@ -1139,7 +1139,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(