From 4d89fb4a12fbfe6473a761e842ab30f328fa6be6 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 27 May 2019 11:03:48 +0200 Subject: [PATCH] [FIX] account_payment_order: Fine-tune amount_company_currency SQL --- .../migrations/9.0.1.0.0/pre-migration.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/account_payment_order/migrations/9.0.1.0.0/pre-migration.py b/account_payment_order/migrations/9.0.1.0.0/pre-migration.py index 14e931dcf..b9c87b52e 100644 --- a/account_payment_order/migrations/9.0.1.0.0/pre-migration.py +++ b/account_payment_order/migrations/9.0.1.0.0/pre-migration.py @@ -192,12 +192,13 @@ def populate_computed_fields(env): ) FROM bank_payment_line bpl2 INNER JOIN account_payment_line apl ON apl.bank_line_id = bpl2.id + INNER JOIN account_move_line aml ON aml.id = apl.move_line_id LEFT JOIN currency_rate cr ON ( - cr.currency_id = apl.currency + cr.currency_id = apl.currency_id AND cr.company_id = bpl2.company_id - AND cr.date_start <= COALESCE(apl.date, now()) + AND cr.date_start <= COALESCE(apl.date, aml.date_maturity) AND (cr.date_end is null - OR cr.date_end > COALESCE(apl.date, now())) + OR cr.date_end > COALESCE(apl.date, aml.date_maturity) ) WHERE bpl2.id = bpl.id """, (AsIs(env['res.currency']._select_companies_rates()), ),