From e950bdf0ce1688d70fc2c64cbcc97a5e12ca0289 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 21 Feb 2022 21:39:04 +0100 Subject: [PATCH] [OU-FIX] account_payment_partner: Fill payment mode on lines for draft/cancel invoices If you have some draft or cancel invoices on v12, the account process generates journal items for them, and no payment_mode is populated on them, so we run an SQL for filling it when such incoherence is found. It also serves for other missing payment mode filling (if any) according to the compute method, trasposed to SQL. TT34717 --- .../migrations/13.0.1.0.0/post-migration.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/account_payment_partner/migrations/13.0.1.0.0/post-migration.py b/account_payment_partner/migrations/13.0.1.0.0/post-migration.py index d7979c4b8..cb28e3980 100644 --- a/account_payment_partner/migrations/13.0.1.0.0/post-migration.py +++ b/account_payment_partner/migrations/13.0.1.0.0/post-migration.py @@ -14,3 +14,16 @@ def migrate(env, version): FROM account_invoice ai WHERE ai.id = am.old_invoice_id""", ) + # Fill new move lines created from draft/cancel invoices in account module with the + # proper payment mode following the logic in the compute method + openupgrade.logged_query( + env.cr, + """ + UPDATE account_move_line aml + SET payment_mode_id = am.payment_mode_id + FROM account_move am + WHERE am.id = aml.move_id + AND am.type IN ('out_invoice', 'out_refund', 'in_invoice', 'in_refund') + AND aml.account_internal_type in ('receivable', 'payable') + AND aml.payment_mode_id IS NULL AND am.payment_mode_id IS NOT NULL""", + )