[FIX] account_reconciliation_widget: Don't link counterpart to the statement line

Steps to reproduce the problem:

- Issue an invoice.
- Add a bank statement for paying such invoice.
- Reconcile the statement with the invoice. It gets paid.
- Revert reconciliation from the statement.
- Go again to reconcile the statement line.

Expected behavior: The invoice is available to be reconciled again.

Current behavior: The invoice is not available.

That's because the move line of the AR/AP account was linked to the
statement line in the reconciliation process through the field
`statement_line_id`. That field is used for linking the generated
move lines to the generating statement line, not for other things.

This is probably a bad migration from v13 original code to v14, where
the reconciliation and the datamodel changed.

It includes a migration script that mitigates a bit the problem on
past reconciled invoices, removing such link. It doesn't cover other
AR/AP lines, but at least we keep data consistent for these ones.

TT46644
This commit is contained in:
Pedro M. Baeza
2023-12-27 11:26:08 +01:00
parent a7346b67b0
commit 427e66abec
5 changed files with 27 additions and 5 deletions

View File

@@ -7,7 +7,7 @@ account_reconciliation_widget
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:71c112eed119e92025ed8b56c20e37d22c783f2bcf5d34f57341426b5b441445 !! source digest: sha256:0d52517eebbb28021256df2b908243ec57e21ff06fc619cd39ff1785a6552e12
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png

View File

@@ -3,7 +3,7 @@
{ {
"name": "account_reconciliation_widget", "name": "account_reconciliation_widget",
"version": "14.0.2.0.6", "version": "14.0.2.0.7",
"category": "Accounting", "category": "Accounting",
"license": "AGPL-3", "license": "AGPL-3",
"summary": "Account reconciliation widget", "summary": "Account reconciliation widget",

View File

@@ -0,0 +1,24 @@
# Copyright 2023 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade
@openupgrade.migrate()
def migrate(env, version):
"""Mitigate a bit the problem on past reconciled invoices, for being available
to be reconciled again if we press "Revert reconciliation" on the statement line.
This doesn't cover other AR/AP lines, but at least we keep data consistent for
these ones.
"""
openupgrade.logged_query(
env.cr,
"""
UPDATE account_move_line aml
SET statement_line_id = NULL, statement_id = NULL
FROM account_move am WHERE am.id = aml.move_id
AND aml.statement_line_id IS NOT NULL
AND am.move_type IN ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')
""",
)

View File

@@ -227,8 +227,6 @@ class AccountBankStatementLine(models.Model):
# Create counterpart move lines and reconcile them # Create counterpart move lines and reconcile them
aml_to_reconcile = [] aml_to_reconcile = []
for aml_dict in counterpart_aml_dicts: for aml_dict in counterpart_aml_dicts:
if not aml_dict["move_line"].statement_line_id:
aml_dict["move_line"].write({"statement_line_id": self.id})
if aml_dict["move_line"].partner_id.id: if aml_dict["move_line"].partner_id.id:
aml_dict["partner_id"] = aml_dict["move_line"].partner_id.id aml_dict["partner_id"] = aml_dict["move_line"].partner_id.id
aml_dict["account_id"] = aml_dict["move_line"].account_id.id aml_dict["account_id"] = aml_dict["move_line"].account_id.id

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:71c112eed119e92025ed8b56c20e37d22c783f2bcf5d34f57341426b5b441445 !! source digest: sha256:0d52517eebbb28021256df2b908243ec57e21ff06fc619cd39ff1785a6552e12
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-reconcile/tree/14.0/account_reconciliation_widget"><img alt="OCA/account-reconcile" src="https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-reconcile-14-0/account-reconcile-14-0-account_reconciliation_widget"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-reconcile&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p> <p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-reconcile/tree/14.0/account_reconciliation_widget"><img alt="OCA/account-reconcile" src="https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-reconcile-14-0/account-reconcile-14-0-account_reconciliation_widget"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-reconcile&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module restores account reconciliation widget moved from Odoo community to enterpise in V. 14.0 <p>This module restores account reconciliation widget moved from Odoo community to enterpise in V. 14.0