From 433cfe66e59dbba0bc66b385129b84fea47c1152 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 3 Dec 2019 10:37:26 +0000 Subject: [PATCH] [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) --- addons/account/models/account_payment.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 1c0e45cdc6a..a2438fdad76 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -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: