OpenUpgrade icon indicating copy to clipboard operation
OpenUpgrade copied to clipboard

[13.0 --> 14.0] account payment move not reconciliable

Open remi-filament opened this issue 3 years ago • 4 comments

Module

account

Describe the bug

After migration of v13 DB to v14 using OpenUpgrade, when trying to reconcile a bank statement line with a payment, the following error is raised : The journal entry BNK1/2022/0051 reached an invalid state regarding its related statement line. To be consistent, the journal entry must always have exactly one journal item involving the bank/cash account.

Analyzing this issue, from my understanding, when reconciling a bank statement line with a payment in Odoo v14, Odoo replaces the Bank Suspense Account in account_move (created automatically from bank_statement_line) by account from reconciled move. In this case, since payment were registered on the same account as bank one (512001), this causes the resulting move with 2 lines on the same bank account. Odoo is expecting to have only one bank account in this move and therefore raises the error.

Basically a customer payment in Odoo 13 and before created the following move lines : Debit 50 € on account 512001 (Bank) Credit 50 € on account 411000 (Receivable)

When a payment in Odoo 14 creates the following move lines : Debit 50 € on account 512003 (Outstanding Receipts) Credit 50 € on account 411000 (Receivable)

The workaround consists in rewriting the 512001 in 512003 on outstanding payment move lines. This could be done automatically in post_install script (after outstanding payment account is automatically created in https://github.com/OCA/OpenUpgrade/blob/f96fc323e51a2ee2db8dba5d8e3fb4ee967f8229/openupgrade_scripts/scripts/account/14.0.1.1/post-migration.py#L566) I am not sure though whether this is a good idea to do that in migration script (since it would rewrite past move lines) ?

To Reproduce

Affected versions: migration 13 to 14

Steps to reproduce the behavior:

  1. Register payment on customer invoice (without reconciliation to bank)
  2. Migrate DB to v14
  3. Create bank statement line for the same amount as the above payment
  4. Try reconciling bank statement line and payment, you should get the same UserError as above

Expected behavior Reconciliation is properly handled

remi-filament avatar May 10 '22 10:05 remi-filament

Hi @MiquelRForgeFlow @pedrobaeza do you think it is acceptable to rewrite account_move_lines related to outstanding payments to change bank account to outstanding receipt account (the same should probably be done for outgoing payments as well) ?

remi-filament avatar May 10 '22 10:05 remi-filament

Not sure doing that will have side effects. For now, such outstanding payments in my migrated DBs (if used), have been manually changed.

pedrobaeza avatar May 10 '22 16:05 pedrobaeza

@pedrobaeza From this change from v13 to v14, what is the correct way to handle this error?

kaynnan avatar Feb 12 '24 19:02 kaynnan

Manually fix the wrong journal items.

pedrobaeza avatar Feb 12 '24 19:02 pedrobaeza