[FIX] account: liquidity-line currency journal ok
If we do a payment with:
- a currency different than the journal
- the journal currency the same as company currency
=> it fails, because of the constraint on account.move.line:
> The amount expressed in the secondary currency must be positive when
> account is debited and negative when account is credited.
with code:
```
CHECK(currency_id IS NULL OR company_currency_id IS NULL OR
((currency_id != company_currency_id) AND {conditions on balance}))
```
This happens because in this use case, a NON-NULL currency_id means that
the currency is different than the company currency, this was not taken
into account when creating a liquidity line.
opw-2150267
closes #41244
closes odoo/odoo#41278
X-original-commit: f9d75e3a5442162538c727eb7e4f111c9b792104
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
@@ -482,7 +482,11 @@ class account_payment(models.Model):
|
||||
# Manage custom currency on journal for liquidity line.
|
||||
if payment.journal_id.currency_id and payment.currency_id != payment.journal_id.currency_id:
|
||||
# Custom currency on journal.
|
||||
liquidity_line_currency_id = payment.journal_id.currency_id.id
|
||||
if payment.journal_id.currency_id == company_currency:
|
||||
# Single-currency
|
||||
liquidity_line_currency_id = False
|
||||
else:
|
||||
liquidity_line_currency_id = payment.journal_id.currency_id.id
|
||||
liquidity_amount = company_currency._convert(
|
||||
balance, payment.journal_id.currency_id, payment.company_id, payment.payment_date)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user