mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[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
This commit is contained in:
@@ -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""",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user