diff --git a/account_move_reconcile_helper/README.rst b/account_move_reconcile_helper/README.rst new file mode 100644 index 0000000000..256ad58b62 --- /dev/null +++ b/account_move_reconcile_helper/README.rst @@ -0,0 +1,83 @@ +============================= +Account Move Reconcile Helper +============================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github + :target: https://github.com/OCA/account-reconcile/tree/14.0/account_move_reconcile_helper + :alt: OCA/account-reconcile +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-reconcile-14-0/account-reconcile-14-0-account_move_reconcile_helper + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/98/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + + +Provides tools to facilitate reconciliation. + +* Display a button on Journal Items to show reconciled lines. +* Added Balance field in Journal Items (this feature + is provided by account_balance_line). + +.. image:: https://raw.githubusercontent.com/OCA/account-reconcile/14.0/account_move_reconcile_helper/static/docs/journal_items.png + :alt: Journal items + :scale: 50 % + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* ACSONE SA/NV + +Contributors +~~~~~~~~~~~~ + +* Benjamin Willig +* Kitti U. + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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_move_reconcile_helper/__init__.py b/account_move_reconcile_helper/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/account_move_reconcile_helper/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_move_reconcile_helper/__manifest__.py b/account_move_reconcile_helper/__manifest__.py new file mode 100644 index 0000000000..4dd75e04f0 --- /dev/null +++ b/account_move_reconcile_helper/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2017 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Account Move Reconcile Helper", + "summary": "Provides tools to facilitate reconciliation", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-reconcile", + "depends": ["account"], + "data": ["views/account_move_line.xml"], + "installable": True, +} diff --git a/account_move_reconcile_helper/i18n/account_move_reconcile_helper.pot b/account_move_reconcile_helper/i18n/account_move_reconcile_helper.pot new file mode 100644 index 0000000000..86fb6c2a20 --- /dev/null +++ b/account_move_reconcile_helper/i18n/account_move_reconcile_helper.pot @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_move_reconcile_helper +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_move_reconcile_helper +#: model:ir.model.fields,field_description:account_move_reconcile_helper.field_account_move_line__display_name +msgid "Display Name" +msgstr "" + +#. module: account_move_reconcile_helper +#: model:ir.model.fields,field_description:account_move_reconcile_helper.field_account_move_line__id +msgid "ID" +msgstr "" + +#. module: account_move_reconcile_helper +#: model:ir.model,name:account_move_reconcile_helper.model_account_move_line +msgid "Journal Item" +msgstr "" + +#. module: account_move_reconcile_helper +#: model:ir.model.fields,field_description:account_move_reconcile_helper.field_account_move_line____last_update +msgid "Last Modified on" +msgstr "" + +#. module: account_move_reconcile_helper +#: model:ir.model.fields,field_description:account_move_reconcile_helper.field_account_move_line__reconcile_line_ids +#: model_terms:ir.ui.view,arch_db:account_move_reconcile_helper.account_move_line_tree_view +msgid "Reconciled lines" +msgstr "" diff --git a/account_move_reconcile_helper/i18n/es.po b/account_move_reconcile_helper/i18n/es.po new file mode 100644 index 0000000000..f7dfef8244 --- /dev/null +++ b/account_move_reconcile_helper/i18n/es.po @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_move_reconcile_helper +# +# Translators: +# enjolras , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-03-09 01:44+0000\n" +"PO-Revision-Date: 2022-04-11 19:05+0000\n" +"Last-Translator: Dept. Técnico \n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: account_move_reconcile_helper +#: model:ir.model,name:account_move_reconcile_helper.model_account_move_line +msgid "Journal Item" +msgstr "Apunte contable" + +#. module: account_move_reconcile_helper +#: model:ir.model.fields,field_description:account_move_reconcile_helper.field_account_move_line__partial_reconciliation_in_progress +msgid "Partial Reconciliation In Progress" +msgstr "Reconciliación parcial en progreso" + +#. module: account_move_reconcile_helper +#: model:ir.model.fields,field_description:account_move_reconcile_helper.field_account_move_line__reconcile_line_ids +#: model_terms:ir.ui.view,arch_db:account_move_reconcile_helper.account_move_line_tree_view +msgid "Reconciled lines" +msgstr "Líneas reconciliadas" diff --git a/account_move_reconcile_helper/i18n/fr.po b/account_move_reconcile_helper/i18n/fr.po new file mode 100644 index 0000000000..4da32631ba --- /dev/null +++ b/account_move_reconcile_helper/i18n/fr.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_move_reconcile_helper +# +# Translators: +# Quentin THEURET , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-03-20 20:58+0000\n" +"PO-Revision-Date: 2018-03-20 20:58+0000\n" +"Last-Translator: Quentin THEURET , 2018\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: account_move_reconcile_helper +#: model:ir.model,name:account_move_reconcile_helper.model_account_move_line +msgid "Journal Item" +msgstr "Écriture comptable" + +#. module: account_move_reconcile_helper +#: model:ir.model.fields,field_description:account_move_reconcile_helper.field_account_move_line__partial_reconciliation_in_progress +#, fuzzy +#| msgid "Partial reconciliation in progress" +msgid "Partial Reconciliation In Progress" +msgstr "Lettrage partiel en cours" + +#. module: account_move_reconcile_helper +#: model:ir.model.fields,field_description:account_move_reconcile_helper.field_account_move_line__reconcile_line_ids +#: model_terms:ir.ui.view,arch_db:account_move_reconcile_helper.account_move_line_tree_view +msgid "Reconciled lines" +msgstr "Lignes lettrées" diff --git a/account_move_reconcile_helper/i18n/hr.po b/account_move_reconcile_helper/i18n/hr.po new file mode 100644 index 0000000000..d7738bd31e --- /dev/null +++ b/account_move_reconcile_helper/i18n/hr.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_move_reconcile_helper +# +# Translators: +# Bole , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-03-09 01:44+0000\n" +"PO-Revision-Date: 2019-11-13 14:34+0000\n" +"Last-Translator: Bole \n" +"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=" +"4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"X-Generator: Weblate 3.8\n" + +#. module: account_move_reconcile_helper +#: model:ir.model,name:account_move_reconcile_helper.model_account_move_line +msgid "Journal Item" +msgstr "Stavka dnevnika" + +#. module: account_move_reconcile_helper +#: model:ir.model.fields,field_description:account_move_reconcile_helper.field_account_move_line__partial_reconciliation_in_progress +msgid "Partial Reconciliation In Progress" +msgstr "Djelomično zatvaranju u postupku" + +#. module: account_move_reconcile_helper +#: model:ir.model.fields,field_description:account_move_reconcile_helper.field_account_move_line__reconcile_line_ids +#: model_terms:ir.ui.view,arch_db:account_move_reconcile_helper.account_move_line_tree_view +msgid "Reconciled lines" +msgstr "Zatvorene stavke" diff --git a/account_move_reconcile_helper/models/__init__.py b/account_move_reconcile_helper/models/__init__.py new file mode 100644 index 0000000000..8795b3bea6 --- /dev/null +++ b/account_move_reconcile_helper/models/__init__.py @@ -0,0 +1 @@ +from . import account_move_line diff --git a/account_move_reconcile_helper/models/account_move_line.py b/account_move_reconcile_helper/models/account_move_line.py new file mode 100644 index 0000000000..a3e7701c56 --- /dev/null +++ b/account_move_reconcile_helper/models/account_move_line.py @@ -0,0 +1,58 @@ +# Copyright 2017 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class AccountMoveLine(models.Model): + + _inherit = "account.move.line" + + reconcile_line_ids = fields.One2many( + compute="_compute_reconciled_lines", + comodel_name="account.move.line", + string="Reconciled lines", + ) + + def _compute_reconciled_lines(self): + for rec in self: + rec.reconcile_line_ids = rec._get_reconciled_lines() + + def _get_reconciled_lines(self, move_lines=None): + """ + Returns lines which were reconciled directly or indirectly with + current lines given in self. + + If A has been reconciled (or partially) with B, and B with C. This + method will returns A, B, and C. + + :param move_lines: found moves lines to avoid recursivity + :return: recordset('account.move.line') + """ + move_lines = move_lines or self.env[self._name] + + for line in self: + if line.full_reconcile_id: + matched_lines = line.full_reconcile_id.reconciled_line_ids + elif line.credit > 0: + matched_lines = line.matched_debit_ids.mapped("debit_move_id") + else: + matched_lines = line.matched_credit_ids.mapped("credit_move_id") + + if not matched_lines: + continue + + move_lines |= line + + for matched_line in matched_lines: + if matched_line not in move_lines: + move_lines |= matched_line + move_lines |= matched_line._get_reconciled_lines(move_lines) + + return move_lines + + def open_full_reconcile_view(self): + view = "account.action_account_moves_all_a" + action = self.env["ir.actions.act_window"]._for_xml_id(view) + action["domain"] = [("id", "in", self.mapped("reconcile_line_ids").ids)] + return action diff --git a/account_move_reconcile_helper/readme/CONTRIBUTORS.rst b/account_move_reconcile_helper/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..f833d17454 --- /dev/null +++ b/account_move_reconcile_helper/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Benjamin Willig +* Kitti U. diff --git a/account_move_reconcile_helper/readme/DESCRIPTION.rst b/account_move_reconcile_helper/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..984783766f --- /dev/null +++ b/account_move_reconcile_helper/readme/DESCRIPTION.rst @@ -0,0 +1,10 @@ + +Provides tools to facilitate reconciliation. + +* Display a button on Journal Items to show reconciled lines. +* Added Balance field in Journal Items (this feature + is provided by account_balance_line). + +.. image:: ./static/docs/journal_items.png + :alt: Journal items + :scale: 50 % diff --git a/account_move_reconcile_helper/static/description/icon.png b/account_move_reconcile_helper/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/account_move_reconcile_helper/static/description/icon.png differ diff --git a/account_move_reconcile_helper/static/description/index.html b/account_move_reconcile_helper/static/description/index.html new file mode 100644 index 0000000000..7ce0d87146 --- /dev/null +++ b/account_move_reconcile_helper/static/description/index.html @@ -0,0 +1,426 @@ + + + + + + +Account Move Reconcile Helper + + + +
+

Account Move Reconcile Helper

+ + +

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

+

Provides tools to facilitate reconciliation.

+
    +
  • Display a button on Journal Items to show reconciled lines.
  • +
  • Added Balance field in Journal Items (this feature +is provided by account_balance_line).
  • +
+Journal items +

Table of contents

+ +
+

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

+
    +
  • ACSONE SA/NV
  • +
+
+
+

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_move_reconcile_helper/static/docs/journal_items.png b/account_move_reconcile_helper/static/docs/journal_items.png new file mode 100644 index 0000000000..0baef65461 Binary files /dev/null and b/account_move_reconcile_helper/static/docs/journal_items.png differ diff --git a/account_move_reconcile_helper/tests/__init__.py b/account_move_reconcile_helper/tests/__init__.py new file mode 100644 index 0000000000..135a0ef450 --- /dev/null +++ b/account_move_reconcile_helper/tests/__init__.py @@ -0,0 +1 @@ +from . import test_account_move_reconcile_helper diff --git a/account_move_reconcile_helper/tests/test_account_move_reconcile_helper.py b/account_move_reconcile_helper/tests/test_account_move_reconcile_helper.py new file mode 100644 index 0000000000..9c43657b59 --- /dev/null +++ b/account_move_reconcile_helper/tests/test_account_move_reconcile_helper.py @@ -0,0 +1,113 @@ +# Copyright 2017 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestAccountMoveReconcileHelper(TransactionCase): + def setUp(self): + super(TestAccountMoveReconcileHelper, self).setUp() + self.AccountObj = self.env["account.account"] + self.AccountJournalObj = self.env["account.journal"] + self.AccountMoveObj = self.env["account.move"] + self.AccountMoveLineObj = self.env["account.move.line"] + + self.account_type_recv = self.env.ref("account.data_account_type_receivable") + self.account_type_rev = self.env.ref("account.data_account_type_revenue") + + self.account_recv = self.AccountObj.create( + { + "code": "MRH-RECVT", + "name": "Receivable (test)", + "reconcile": True, + "user_type_id": self.account_type_recv.id, + } + ) + self.account_sale = self.AccountObj.create( + { + "code": "MRH-SALET", + "name": "Receivable (sale)", + "reconcile": True, + "user_type_id": self.account_type_rev.id, + } + ) + + self.sales_journal = self.AccountJournalObj.create( + { + "name": "Sales journal", + "code": "MRH-SAJT", + "type": "sale", + "default_account_id": self.account_sale.id, + } + ) + + def create_account_move(self, amount, debit_account, credit_account): + return self.AccountMoveObj.create( + { + "journal_id": self.sales_journal.id, + "line_ids": [ + ( + 0, + 0, + { + "name": "Receivable line", + "account_id": debit_account.id, + "debit": amount, + }, + ), + ( + 0, + 0, + { + "name": "Sales line", + "account_id": credit_account.id, + "credit": amount, + }, + ), + ], + } + ) + + def test_01_partial_reconcile(self): + base_move = self.create_account_move(5000, self.account_recv, self.account_sale) + + move1 = self.create_account_move(1000, self.account_sale, self.account_recv) + + move2 = self.create_account_move(1000, self.account_sale, self.account_recv) + + lines = self.AccountMoveLineObj.search( + [ + ("move_id", "in", [base_move.id, move1.id, move2.id]), + ("account_id", "=", self.account_recv.id), + ] + ) + lines.mapped("move_id").action_post() + lines.reconcile() + # For v13, need to force compute + lines._compute_reconciled_lines() + + for line in lines: + self.assertEqual(line.reconcile_line_ids, lines) + + def test_02_full_reconcile(self): + base_move = self.create_account_move(5000, self.account_recv, self.account_sale) + + move2 = self.create_account_move(2500, self.account_sale, self.account_recv) + move3 = self.create_account_move(2500, self.account_sale, self.account_recv) + + lines = self.AccountMoveLineObj.search( + [ + ("move_id", "in", [base_move.id, move2.id, move3.id]), + ("account_id", "=", self.account_recv.id), + ] + ) + lines.mapped("move_id").action_post() + lines.reconcile() + # For v13, need to force compute + lines._compute_reconciled_lines() + + for line in lines: + self.assertEqual(line.reconcile_line_ids, lines) + self.assertEqual( + line.full_reconcile_id.reconciled_line_ids, line.reconcile_line_ids + ) diff --git a/account_move_reconcile_helper/views/account_move_line.xml b/account_move_reconcile_helper/views/account_move_line.xml new file mode 100644 index 0000000000..ff0f096079 --- /dev/null +++ b/account_move_reconcile_helper/views/account_move_line.xml @@ -0,0 +1,34 @@ + + + + + account.move.line.tree (in account_move_reconcile_helper) + account.move.line + + + +