unit_price and quantity could be None during on_change calls

issue2740
(transplanted from 106b5697c8ac029aaff864f8cf556fa91ab2ef00)
This commit is contained in:
Cédric Krier committed 2012-08-07 12:53:48 +02:00
1 parent d98291b321
commit 10268bbed6
1 file changed
+4 -4
+4 -4
View File
@@ -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(