[FIX] account_reconcile_oca: Fix foreign currency
parent
2430b8082c
commit
4a5e33919d
|
@ -144,13 +144,16 @@ class AccountBankStatementLine(models.Model):
|
|||
new_data,
|
||||
self.reconcile_data_info["reconcile_auxiliary_id"],
|
||||
self.manual_reference,
|
||||
exchange_recompute=True,
|
||||
)
|
||||
self.can_reconcile = self.reconcile_data_info.get("can_reconcile", False)
|
||||
self.add_account_move_line_id = False
|
||||
|
||||
def _recompute_suspense_line(self, data, reconcile_auxiliary_id, manual_reference):
|
||||
def _recompute_suspense_line(
|
||||
self, data, reconcile_auxiliary_id, manual_reference, exchange_recompute=False
|
||||
):
|
||||
reconcile_auxiliary_id = self._compute_exchange_rate(
|
||||
data, reconcile_auxiliary_id
|
||||
data, reconcile_auxiliary_id, exchange_recompute=exchange_recompute
|
||||
)
|
||||
can_reconcile = True
|
||||
total_amount = 0
|
||||
|
@ -406,7 +409,11 @@ class AccountBankStatementLine(models.Model):
|
|||
new_data.append(new_line)
|
||||
return new_data, reconcile_auxiliary_id
|
||||
|
||||
def _compute_exchange_rate(self, data, reconcile_auxiliary_id):
|
||||
def _compute_exchange_rate(
|
||||
self, data, reconcile_auxiliary_id, exchange_recompute=False
|
||||
):
|
||||
if not exchange_recompute:
|
||||
return reconcile_auxiliary_id
|
||||
foreign_currency = (
|
||||
self.currency_id != self.company_id.currency_id
|
||||
or self.foreign_currency_id
|
||||
|
@ -429,6 +436,7 @@ class AccountBankStatementLine(models.Model):
|
|||
"date": fields.Date.to_string(self.date),
|
||||
"name": self.payment_ref or self.name,
|
||||
"amount": -amount,
|
||||
"net_amount": -amount,
|
||||
"credit": amount if amount > 0 else 0.0,
|
||||
"debit": -amount if amount < 0 else 0.0,
|
||||
"kind": "other",
|
||||
|
@ -458,6 +466,7 @@ class AccountBankStatementLine(models.Model):
|
|||
data, res["model"], reconcile_auxiliary_id
|
||||
),
|
||||
self.manual_reference,
|
||||
exchange_recompute=True,
|
||||
)
|
||||
elif res and res.get("amls"):
|
||||
amount = self.amount_total_signed
|
||||
|
@ -468,7 +477,10 @@ class AccountBankStatementLine(models.Model):
|
|||
amount -= line_data.get("amount")
|
||||
data.append(line_data)
|
||||
return self._recompute_suspense_line(
|
||||
data, reconcile_auxiliary_id, self.manual_reference
|
||||
data,
|
||||
reconcile_auxiliary_id,
|
||||
self.manual_reference,
|
||||
exchange_recompute=True,
|
||||
)
|
||||
return self._recompute_suspense_line(
|
||||
data
|
||||
|
@ -661,6 +673,7 @@ class AccountBankStatementLine(models.Model):
|
|||
data, res["model"], reconcile_auxiliary_id
|
||||
),
|
||||
self.manual_reference,
|
||||
exchange_recompute=True,
|
||||
)
|
||||
elif res.get("amls"):
|
||||
amount = self.amount
|
||||
|
@ -671,7 +684,10 @@ class AccountBankStatementLine(models.Model):
|
|||
amount -= line_data.get("amount")
|
||||
data.append(line_data)
|
||||
data = record._recompute_suspense_line(
|
||||
data, reconcile_auxiliary_id, self.manual_reference
|
||||
data,
|
||||
reconcile_auxiliary_id,
|
||||
self.manual_reference,
|
||||
exchange_recompute=True,
|
||||
)
|
||||
if not data.get("can_reconcile"):
|
||||
continue
|
||||
|
@ -721,7 +737,10 @@ class AccountBankStatementLine(models.Model):
|
|||
else:
|
||||
new_data.append(line)
|
||||
self.reconcile_data_info = self._recompute_suspense_line(
|
||||
new_data, reconcile_auxiliary_id, self.manual_reference
|
||||
new_data,
|
||||
reconcile_auxiliary_id,
|
||||
self.manual_reference,
|
||||
exchange_recompute=True,
|
||||
)
|
||||
self.can_reconcile = self.reconcile_data_info.get("can_reconcile", False)
|
||||
|
||||
|
|
Loading…
Reference in New Issue