Bug
This commit is contained in:
@@ -1119,8 +1119,9 @@ class Line(DescriptionOriginMixin, MoveLineMixin, ModelSQL, ModelView):
|
||||
return line.move.id
|
||||
|
||||
def get_rate(self,name=None):
|
||||
if self.amount_second_currency:
|
||||
return round((self.credit if self.credit else self.debit) / abs(self.amount_second_currency),6)
|
||||
amount = self.credit if self.credit else self.debit
|
||||
if self.amount_second_currency and amount:
|
||||
return round(abs(self.amount_second_currency) / amount, 6)
|
||||
|
||||
@fields.depends(
|
||||
'debit', 'credit',
|
||||
@@ -1163,7 +1164,14 @@ class Line(DescriptionOriginMixin, MoveLineMixin, ModelSQL, ModelView):
|
||||
if not self.rate:
|
||||
self.rate = self._get_second_currency_rate()
|
||||
if self.rate:
|
||||
amount = round(self.rate * abs(self.amount_second_currency), 2)
|
||||
company_currency = (
|
||||
self.company.currency if getattr(self, 'company', None)
|
||||
else self.account.company.currency
|
||||
if getattr(self, 'account', None) else None)
|
||||
if not company_currency:
|
||||
return
|
||||
amount = company_currency.round(
|
||||
abs(self.amount_second_currency) / self.rate)
|
||||
if self.amount_second_currency > 0:
|
||||
self.debit = amount
|
||||
self.credit = Decimal(0)
|
||||
|
||||
Reference in New Issue
Block a user