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""", + )