diff --git a/account_move_reconcile_helper/README.rst b/account_move_reconcile_helper/README.rst new file mode 100644 index 00000000..eb34bd74 --- /dev/null +++ b/account_move_reconcile_helper/README.rst @@ -0,0 +1,86 @@ +============================= +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/12.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-12-0/account-reconcile-12-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/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + + +Provides tools to facilitate reconciliation. + +* Display a button on Journal entries list to show reconciled lines. +* Added Balance field in Journal entries list (this feature + is provided by account_balance_line). + +.. image:: https://raw.githubusercontent.com/OCA/account-reconcile/12.0/account_move_reconcile_helper/static/docs/journal_entries_1.png + :alt: Journal entries + :scale: 50 % + +.. image:: https://raw.githubusercontent.com/OCA/account-reconcile/12.0/account_move_reconcile_helper/static/docs/journal_entries_2.png + :alt: Reconciled lines view + :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 + +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 00000000..0650744f --- /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 00000000..9e8c8bfc --- /dev/null +++ b/account_move_reconcile_helper/__manifest__.py @@ -0,0 +1,17 @@ +# 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': '12.0.1.0.0', + 'license': 'AGPL-3', + 'author': 'ACSONE SA/NV, Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/account-reconcile', + 'depends': [ + 'account_balance_line', + ], + 'data': [ + 'views/account_move_line.xml', + ], +} 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 00000000..c7a5d37d --- /dev/null +++ b/account_move_reconcile_helper/i18n/account_move_reconcile_helper.pot @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_move_reconcile_helper +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.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,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__partial_reconciliation_in_progress +msgid "Partial Reconciliation In Progress" +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 00000000..ca521e8d --- /dev/null +++ b/account_move_reconcile_helper/i18n/es.po @@ -0,0 +1,35 @@ +# 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: 2018-03-09 01:44+0000\n" +"Last-Translator: enjolras , 2018\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" + +#. 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 proceso" + +#. module: account_move_reconcile_helper +#: model:ir.model.fields,field_description:account_move_reconcile_helper.field_account_move_line_reconcile_line_ids +#: model: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 00000000..452abdf2 --- /dev/null +++ b/account_move_reconcile_helper/i18n/fr.po @@ -0,0 +1,35 @@ +# 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 +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: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 00000000..d89261c7 --- /dev/null +++ b/account_move_reconcile_helper/i18n/hr.po @@ -0,0 +1,36 @@ +# 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: 2018-03-09 01:44+0000\n" +"Last-Translator: Bole , 2018\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" + +#. 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 "" + +#. module: account_move_reconcile_helper +#: model:ir.model.fields,field_description:account_move_reconcile_helper.field_account_move_line_reconcile_line_ids +#: model: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/models/__init__.py b/account_move_reconcile_helper/models/__init__.py new file mode 100644 index 00000000..8795b3be --- /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 00000000..2506515f --- /dev/null +++ b/account_move_reconcile_helper/models/account_move_line.py @@ -0,0 +1,71 @@ +# Copyright 2017 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class AccountMoveLine(models.Model): + + _inherit = 'account.move.line' + + partial_reconciliation_in_progress = fields.Boolean( + compute='_compute_partial_reconciliation_in_progress') + reconcile_line_ids = fields.One2many( + compute='_compute_reconciled_lines', + comodel_name='account.move.line', + string="Reconciled lines") + + @api.multi + @api.depends('matched_debit_ids', 'matched_credit_ids') + def _compute_partial_reconciliation_in_progress(self): + for rec in self: + rec.partial_reconciliation_in_progress = ( + bool(rec.matched_debit_ids) or bool(rec.matched_credit_ids)) + + @api.multi + def _compute_reconciled_lines(self): + for rec in self: + rec.reconcile_line_ids = rec._get_reconciled_lines() + + @api.multi + 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 + + @api.multi + def open_full_reconcile_view(self): + action = self.env.ref('account.action_account_moves_all_a').read()[0] + 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 00000000..eea6cac0 --- /dev/null +++ b/account_move_reconcile_helper/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Benjamin Willig diff --git a/account_move_reconcile_helper/readme/DESCRIPTION.rst b/account_move_reconcile_helper/readme/DESCRIPTION.rst new file mode 100644 index 00000000..90a4a8e1 --- /dev/null +++ b/account_move_reconcile_helper/readme/DESCRIPTION.rst @@ -0,0 +1,14 @@ + +Provides tools to facilitate reconciliation. + +* Display a button on Journal entries list to show reconciled lines. +* Added Balance field in Journal entries list (this feature + is provided by account_balance_line). + +.. image:: ./static/docs/journal_entries_1.png + :alt: Journal entries + :scale: 50 % + +.. image:: ./static/docs/journal_entries_2.png + :alt: Reconciled lines view + :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 00000000..3a0328b5 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 00000000..f873c9b5 --- /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 entries list to show reconciled lines.
  • +
  • Added Balance field in Journal entries list (this feature +is provided by account_balance_line).
  • +
+Journal entries +Reconciled lines view +

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_entries_1.png b/account_move_reconcile_helper/static/docs/journal_entries_1.png new file mode 100644 index 00000000..abad0b04 Binary files /dev/null and b/account_move_reconcile_helper/static/docs/journal_entries_1.png differ diff --git a/account_move_reconcile_helper/static/docs/journal_entries_2.png b/account_move_reconcile_helper/static/docs/journal_entries_2.png new file mode 100644 index 00000000..0d4e995f Binary files /dev/null and b/account_move_reconcile_helper/static/docs/journal_entries_2.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 00000000..135a0ef4 --- /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 00000000..32f6c644 --- /dev/null +++ b/account_move_reconcile_helper/tests/test_account_move_reconcile_helper.py @@ -0,0 +1,99 @@ +# 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_credit_account_id': self.account_sale.id, + 'default_debit_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.reconcile() + + for line in lines: + self.assertEquals(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.reconcile() + + for line in lines: + self.assertEquals(line.reconcile_line_ids, lines) + self.assertEquals( + 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 00000000..829960f2 --- /dev/null +++ b/account_move_reconcile_helper/views/account_move_line.xml @@ -0,0 +1,23 @@ + + + + + + + account.move.line.tree (in account_move_reconcile_helper) + account.move.line + + + + + +