diff --git a/purchase.py b/purchase.py index e65096bcf4..ac8367cb01 100644 --- a/purchase.py +++ b/purchase.py @@ -1022,11 +1022,10 @@ class PurchaseLine(ModelSQL, ModelView): def on_change_with_amount(self, vals): currency_obj = self.pool.get('currency.currency') if vals.get('type') == 'line': - if isinstance(vals.get('_parent_purchase.currency'), (int, long)): + currency = vals.get('_parent_purchase.currency') + if currency and isinstance(currency, (int, long)): currency = currency_obj.browse( vals['_parent_purchase.currency']) - else: - currency = vals['_parent_purchase.currency'] amount = Decimal(str(vals.get('quantity') or '0.0')) * \ (vals.get('unit_price') or Decimal('0.0')) if currency: