diff --git a/account_bank_statement_reopen_skip_undo_reconciliation/__init__.py b/account_bank_statement_reopen_skip_undo_reconciliation/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/account_bank_statement_reopen_skip_undo_reconciliation/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_bank_statement_reopen_skip_undo_reconciliation/__manifest__.py b/account_bank_statement_reopen_skip_undo_reconciliation/__manifest__.py new file mode 100644 index 00000000..fee48a20 --- /dev/null +++ b/account_bank_statement_reopen_skip_undo_reconciliation/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2022 ForgeFlow S.L. +# @author Jordi Ballester +# Copyright 2022 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Account Bank Statement Reopen Skip Undo Reconciliation", + "summary": "When reopening a bank statement it will respect the " + "reconciled entries.", + "version": "14.0.1.0.0", + "author": "ForgeFlow, Akretion, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-reconcile", + "category": "Finance", + "depends": ["account"], + "data": ["views/account_bank_statement_views.xml"], + "license": "AGPL-3", + "installable": True, + "auto_install": False, +} diff --git a/account_bank_statement_reopen_skip_undo_reconciliation/models/__init__.py b/account_bank_statement_reopen_skip_undo_reconciliation/models/__init__.py new file mode 100644 index 00000000..efbd6ab5 --- /dev/null +++ b/account_bank_statement_reopen_skip_undo_reconciliation/models/__init__.py @@ -0,0 +1,4 @@ +from . import account_bank_statement +from . import account_bank_statement_line +from . import account_move_line +from . import account_move diff --git a/account_bank_statement_reopen_skip_undo_reconciliation/models/account_bank_statement.py b/account_bank_statement_reopen_skip_undo_reconciliation/models/account_bank_statement.py new file mode 100644 index 00000000..d92b44f9 --- /dev/null +++ b/account_bank_statement_reopen_skip_undo_reconciliation/models/account_bank_statement.py @@ -0,0 +1,15 @@ +# Copyright 2022 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# Copyright 2022 ForgeFlow S.L. +# @author Jordi Ballester +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class AccountBankStatement(models.Model): + _inherit = "account.bank.statement" + + def button_reopen(self): + self = self.with_context(skip_undo_reconciliation=True) + return super(AccountBankStatement, self).button_reopen() diff --git a/account_bank_statement_reopen_skip_undo_reconciliation/models/account_bank_statement_line.py b/account_bank_statement_reopen_skip_undo_reconciliation/models/account_bank_statement_line.py new file mode 100644 index 00000000..3e4f5510 --- /dev/null +++ b/account_bank_statement_reopen_skip_undo_reconciliation/models/account_bank_statement_line.py @@ -0,0 +1,20 @@ +# Copyright 2022 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# Copyright 2022 ForgeFlow S.L. +# @author Jordi Ballester +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + + +from odoo import models + + +class AccountBankStatementLine(models.Model): + _inherit = "account.bank.statement.line" + + def button_undo_reconciliation(self): + if self._context.get("skip_undo_reconciliation"): + return + res = super(AccountBankStatementLine, self).button_undo_reconciliation() + if self.statement_id.state == "open": + self.move_id.button_draft() + return res diff --git a/account_bank_statement_reopen_skip_undo_reconciliation/models/account_move.py b/account_bank_statement_reopen_skip_undo_reconciliation/models/account_move.py new file mode 100644 index 00000000..5fbfabd6 --- /dev/null +++ b/account_bank_statement_reopen_skip_undo_reconciliation/models/account_move.py @@ -0,0 +1,13 @@ +# Copyright 2022 ForgeFlow S.L. +# @author Jordi Ballester +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class AccountMove(models.Model): + _inherit = "account.move" + + def button_draft(self): + moves_to_draft = self.filtered(lambda m: not m.statement_line_id.is_reconciled) + return super(AccountMove, moves_to_draft).button_draft() diff --git a/account_bank_statement_reopen_skip_undo_reconciliation/models/account_move_line.py b/account_bank_statement_reopen_skip_undo_reconciliation/models/account_move_line.py new file mode 100644 index 00000000..db1445e7 --- /dev/null +++ b/account_bank_statement_reopen_skip_undo_reconciliation/models/account_move_line.py @@ -0,0 +1,14 @@ +# Copyright 2022 ForgeFlow S.L. +# @author Jordi Ballester +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + def remove_move_reconcile(self): + if self._context.get("skip_undo_reconciliation"): + return True + return super(AccountMoveLine, self).remove_move_reconcile() diff --git a/account_bank_statement_reopen_skip_undo_reconciliation/readme/CONTRIBUTORS.rst b/account_bank_statement_reopen_skip_undo_reconciliation/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..7d73f962 --- /dev/null +++ b/account_bank_statement_reopen_skip_undo_reconciliation/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* Akretion + * Alexis de Lattre + +* ForgeFlow + * Jordi Ballester Alomar diff --git a/account_bank_statement_reopen_skip_undo_reconciliation/readme/DESCRIPTION.rst b/account_bank_statement_reopen_skip_undo_reconciliation/readme/DESCRIPTION.rst new file mode 100644 index 00000000..450d5a31 --- /dev/null +++ b/account_bank_statement_reopen_skip_undo_reconciliation/readme/DESCRIPTION.rst @@ -0,0 +1,12 @@ +After installing this module when you press the button "Reset to New" on a bank +statement that is in status 'Processing' the application will not unreconcile +or set to draft any previous reconciled bank statement lines. + +The reconciled bank statement lines remain posted and reconciled. As soon as +you manually unreconcile the line the associated journal entry will be reset +back to the Draft status, if the statement is in "New" status. + +This feature improves the usability of the bank statements, as it may be +frequent for a user to adjust the statement lines during the reconciliation +process, needing to Reset the status of the statement back to new in order to +introduce changes. diff --git a/account_bank_statement_reopen_skip_undo_reconciliation/static/description/icon.png b/account_bank_statement_reopen_skip_undo_reconciliation/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/account_bank_statement_reopen_skip_undo_reconciliation/static/description/icon.png differ diff --git a/account_bank_statement_reopen_skip_undo_reconciliation/static/description/index.html b/account_bank_statement_reopen_skip_undo_reconciliation/static/description/index.html new file mode 100644 index 00000000..2c169cd1 --- /dev/null +++ b/account_bank_statement_reopen_skip_undo_reconciliation/static/description/index.html @@ -0,0 +1,435 @@ + + + + + + +Account Mass Reconcile by Purchase Line + + + +
+

Account Mass Reconcile by Purchase Line

+ + +

Beta License: AGPL-3 OCA/account-reconcile Translate me on Weblate Try me on Runbot

+

This module extends the functionality of account_mass_reconcile and +allow an user to reconcile debits and credits of an Account +using the PO Line and Product as key fields. This type of +reconciliation is to be used in the context of the Perpetual Inventory +accounting system, with the accrual account ‘Goods Received Not Invoiced’.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  • Go to ‘Invoicing / Accounting / Actions / Mass Automatic Reconcile’.
  • +
  • Create a new reconciliation profile, and select a new configuration entry +with type ‘Advanced. Product, purchase order line’.
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/account-reconcile project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_bank_statement_reopen_skip_undo_reconciliation/tests/__init__.py b/account_bank_statement_reopen_skip_undo_reconciliation/tests/__init__.py new file mode 100644 index 00000000..33a86128 --- /dev/null +++ b/account_bank_statement_reopen_skip_undo_reconciliation/tests/__init__.py @@ -0,0 +1 @@ +from . import test_account_bank_statement diff --git a/account_bank_statement_reopen_skip_undo_reconciliation/tests/test_account_bank_statement.py b/account_bank_statement_reopen_skip_undo_reconciliation/tests/test_account_bank_statement.py new file mode 100644 index 00000000..539aefd7 --- /dev/null +++ b/account_bank_statement_reopen_skip_undo_reconciliation/tests/test_account_bank_statement.py @@ -0,0 +1,83 @@ +# Copyright 2022 ForgeFlow S.L. +# @author Jordi Ballester +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import fields +from odoo.tests import tagged + +from odoo.addons.account.tests.test_account_bank_statement import ( + TestAccountBankStatementCommon, +) + + +@tagged("post_install", "-at_install") +class TestAccountBankStatementLine(TestAccountBankStatementCommon): + def test_button_undo_reconciliation(self): + statement = self.env["account.bank.statement"].create( + { + "name": "test_statement", + "date": "2019-01-01", + "journal_id": self.bank_journal_2.id, + "line_ids": [ + ( + 0, + 0, + { + "date": "2019-01-01", + "payment_ref": "line_1", + "partner_id": self.partner_a.id, + "amount": 1000, + }, + ), + ( + 0, + 0, + { + "date": "2019-01-01", + "payment_ref": "line_2", + "partner_id": self.partner_a.id, + "amount": 2000, + }, + ), + ], + } + ) + statement_line = statement.line_ids[0] + + test_invoice = self.env["account.move"].create( + [ + { + "move_type": "out_invoice", + "invoice_date": fields.Date.from_string("2016-01-01"), + "date": fields.Date.from_string("2016-01-01"), + "partner_id": self.partner_a.id, + "invoice_line_ids": [ + ( + 0, + None, + { + "name": "counterpart line, same amount", + "account_id": self.company_data[ + "default_account_revenue" + ].id, + "quantity": 1, + "price_unit": 1000, + }, + ), + ], + } + ] + ) + test_invoice.action_post() + statement.button_post() + counterpart_lines = test_invoice.mapped("line_ids").filtered( + lambda line: line.account_internal_type in ("receivable", "payable") + ) + statement_line.reconcile([{"id": counterpart_lines[0].id}]) + self.assertEqual(counterpart_lines.reconciled, True) + statement.button_reopen() + self.assertEqual(counterpart_lines.reconciled, True) + self.assertEqual(statement_line.move_id.state, "posted") + second_statement_line = statement.line_ids[0] + self.assertEqual(second_statement_line.move_id.state, "draft") + statement_line.button_undo_reconciliation() + self.assertEqual(statement_line.move_id.state, "draft") diff --git a/account_bank_statement_reopen_skip_undo_reconciliation/views/account_bank_statement_views.xml b/account_bank_statement_reopen_skip_undo_reconciliation/views/account_bank_statement_views.xml new file mode 100644 index 00000000..4fbf2f74 --- /dev/null +++ b/account_bank_statement_reopen_skip_undo_reconciliation/views/account_bank_statement_views.xml @@ -0,0 +1,15 @@ + + + account.bank.statement.form + account.bank.statement + + 1 + + + + + diff --git a/setup/account_bank_statement_reopen_skip_undo_reconciliation/odoo/addons/account_bank_statement_reopen_skip_undo_reconciliation b/setup/account_bank_statement_reopen_skip_undo_reconciliation/odoo/addons/account_bank_statement_reopen_skip_undo_reconciliation new file mode 120000 index 00000000..a587f984 --- /dev/null +++ b/setup/account_bank_statement_reopen_skip_undo_reconciliation/odoo/addons/account_bank_statement_reopen_skip_undo_reconciliation @@ -0,0 +1 @@ +../../../../account_bank_statement_reopen_skip_undo_reconciliation \ No newline at end of file diff --git a/setup/account_bank_statement_reopen_skip_undo_reconciliation/setup.py b/setup/account_bank_statement_reopen_skip_undo_reconciliation/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/account_bank_statement_reopen_skip_undo_reconciliation/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)