From 914f880e6337e0356de7ef42fb01386832ef7718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Marques?= Date: Thu, 10 Sep 2020 15:52:52 +0100 Subject: [PATCH] [ADD] account_bank_statement_clear_partner: Clear all partners in a bank statement --- .../README.rst | 91 ++++ .../__init__.py | 3 + .../__manifest__.py | 18 + .../models/__init__.py | 3 + .../models/account_bank_statement.py | 13 + .../readme/CONFIGURE.rst | 0 .../readme/CONTRIBUTORS.rst | 5 + .../readme/DESCRIPTION.rst | 2 + .../readme/USAGE.rst | 9 + .../static/description/index.html | 436 ++++++++++++++++++ .../tests/__init__.py | 3 + ...est_account_bank_statement_clear_patner.py | 83 ++++ .../views/account_bank_statement_views.xml | 15 + 13 files changed, 681 insertions(+) create mode 100644 account_bank_statement_clear_partner/README.rst create mode 100644 account_bank_statement_clear_partner/__init__.py create mode 100644 account_bank_statement_clear_partner/__manifest__.py create mode 100644 account_bank_statement_clear_partner/models/__init__.py create mode 100644 account_bank_statement_clear_partner/models/account_bank_statement.py create mode 100644 account_bank_statement_clear_partner/readme/CONFIGURE.rst create mode 100644 account_bank_statement_clear_partner/readme/CONTRIBUTORS.rst create mode 100644 account_bank_statement_clear_partner/readme/DESCRIPTION.rst create mode 100644 account_bank_statement_clear_partner/readme/USAGE.rst create mode 100644 account_bank_statement_clear_partner/static/description/index.html create mode 100644 account_bank_statement_clear_partner/tests/__init__.py create mode 100644 account_bank_statement_clear_partner/tests/test_account_bank_statement_clear_patner.py create mode 100644 account_bank_statement_clear_partner/views/account_bank_statement_views.xml diff --git a/account_bank_statement_clear_partner/README.rst b/account_bank_statement_clear_partner/README.rst new file mode 100644 index 0000000..569aee5 --- /dev/null +++ b/account_bank_statement_clear_partner/README.rst @@ -0,0 +1,91 @@ +========================================== +Clear all partners in bank statement lines +========================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |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%2Fbank--statement--import-lightgray.png?logo=github + :target: https://github.com/OCA/bank-statement-import/tree/12.0/account_bank_statement_clear_partner + :alt: OCA/bank-statement-import +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/bank-statement-import-12-0/bank-statement-import-12-0-account_bank_statement_clear_partner + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/174/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + + +This module extends the functionality of `account_bank_statement` to allow you to **Clear all partners in a bank statement lines** where the line hasn't been **reconciled**. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + + +To use this module, you need to: + +#. Enable the **Show Full Accounting Features** option for your user under **Settings** > **Users & Companies** > **Users** +#. Go to **Invoicing** +#. Click on the name of a bank journal (**Bank** in demo data for example) +#. Select a bank statement +#. Press "Clear partners" button located on the header. +#. All the partners in non reconciled lines will be cleared. + +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 +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + + +* `Tecnativa `__: + + * João Marques + * Pedro M. Baeza + +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/bank-statement-import `_ 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_clear_partner/__init__.py b/account_bank_statement_clear_partner/__init__.py new file mode 100644 index 0000000..31660d6 --- /dev/null +++ b/account_bank_statement_clear_partner/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/account_bank_statement_clear_partner/__manifest__.py b/account_bank_statement_clear_partner/__manifest__.py new file mode 100644 index 0000000..553c600 --- /dev/null +++ b/account_bank_statement_clear_partner/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2020 Tecnativa - João Marques +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Clear all partners in bank statement lines", + "version": "12.0.1.0.0", + # see https://odoo-community.org/page/development-status + "development_status": "Production/Stable", + "category": "Invoicing Management", + "website": "https://github.com/OCA/bank-statement-import", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": [ + 'account', + ], + "data": [ + "views/account_bank_statement_views.xml" + ] +} diff --git a/account_bank_statement_clear_partner/models/__init__.py b/account_bank_statement_clear_partner/models/__init__.py new file mode 100644 index 0000000..2320ddc --- /dev/null +++ b/account_bank_statement_clear_partner/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import account_bank_statement diff --git a/account_bank_statement_clear_partner/models/account_bank_statement.py b/account_bank_statement_clear_partner/models/account_bank_statement.py new file mode 100644 index 0000000..30cf2bc --- /dev/null +++ b/account_bank_statement_clear_partner/models/account_bank_statement.py @@ -0,0 +1,13 @@ +# Copyright 2020 Tecnativa - João Marques +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class AccountBankStatementClearPartner(models.Model): + _inherit = "account.bank.statement" + + def clear_partners(self): + self.mapped("line_ids").filtered( + lambda x: not x.journal_entry_ids and not x.account_id + ).write({"partner_id": False}) diff --git a/account_bank_statement_clear_partner/readme/CONFIGURE.rst b/account_bank_statement_clear_partner/readme/CONFIGURE.rst new file mode 100644 index 0000000..e69de29 diff --git a/account_bank_statement_clear_partner/readme/CONTRIBUTORS.rst b/account_bank_statement_clear_partner/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..3656031 --- /dev/null +++ b/account_bank_statement_clear_partner/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ + +* `Tecnativa `__: + + * João Marques + * Pedro M. Baeza diff --git a/account_bank_statement_clear_partner/readme/DESCRIPTION.rst b/account_bank_statement_clear_partner/readme/DESCRIPTION.rst new file mode 100644 index 0000000..5a2fe1d --- /dev/null +++ b/account_bank_statement_clear_partner/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ + +This module extends the functionality of `account_bank_statement` to allow you to **Clear all partners in a bank statement lines** where the line hasn't been **reconciled**. diff --git a/account_bank_statement_clear_partner/readme/USAGE.rst b/account_bank_statement_clear_partner/readme/USAGE.rst new file mode 100644 index 0000000..82d66d8 --- /dev/null +++ b/account_bank_statement_clear_partner/readme/USAGE.rst @@ -0,0 +1,9 @@ + +To use this module, you need to: + +#. Enable the **Show Full Accounting Features** option for your user under **Settings** > **Users & Companies** > **Users** +#. Go to **Invoicing** +#. Click on the name of a bank journal (**Bank** in demo data for example) +#. Select a bank statement +#. Press "Clear partners" button located on the header. +#. All the partners in non reconciled lines will be cleared. diff --git a/account_bank_statement_clear_partner/static/description/index.html b/account_bank_statement_clear_partner/static/description/index.html new file mode 100644 index 0000000..cf52edd --- /dev/null +++ b/account_bank_statement_clear_partner/static/description/index.html @@ -0,0 +1,436 @@ + + + + + + +Clear all partners in bank statement lines + + + +
+

Clear all partners in bank statement lines

+ + +

Production/Stable License: AGPL-3 OCA/bank-statement-import Translate me on Weblate Try me on Runbot

+

This module extends the functionality of account_bank_statement to allow you to Clear all partners in a bank statement lines where the line hasn’t been reconciled.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Enable the Show Full Accounting Features option for your user under Settings > Users & Companies > Users
  2. +
  3. Go to Invoicing
  4. +
  5. Click on the name of a bank journal (Bank in demo data for example)
  6. +
  7. Select a bank statement
  8. +
  9. Press “Clear partners” button located on the header.
  10. +
  11. All the partners in non reconciled lines will be cleared.
  12. +
+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • João Marques
    • +
    • Pedro M. Baeza
    • +
    +
  • +
+
+
+

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/bank-statement-import 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_clear_partner/tests/__init__.py b/account_bank_statement_clear_partner/tests/__init__.py new file mode 100644 index 0000000..6c2427e --- /dev/null +++ b/account_bank_statement_clear_partner/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0 + +from . import test_account_bank_statement_clear_patner diff --git a/account_bank_statement_clear_partner/tests/test_account_bank_statement_clear_patner.py b/account_bank_statement_clear_partner/tests/test_account_bank_statement_clear_patner.py new file mode 100644 index 0000000..da4b968 --- /dev/null +++ b/account_bank_statement_clear_partner/tests/test_account_bank_statement_clear_patner.py @@ -0,0 +1,83 @@ +# Copyright 2020 Tecnativa - João Marques +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0 + +from odoo.tests import common + + +class TestAccountBankStatementClearPartner(common.SavepointCase): + @classmethod + def setUpClass(cls): + super(TestAccountBankStatementClearPartner, cls).setUpClass() + cls.partner_1 = cls.env['res.partner'].create( + { + "name": "Partner 1", + } + ) + cls.partner_2 = cls.env['res.partner'].create( + { + "name": "Partner 2", + } + ) + cls.account_type_1 = cls.env['account.account.type'].create({ + "name": "Test Account Type 1", + "type": "other" + }) + cls.account_1 = cls.env['account.account'].create({ + "name": "Test Account 1", + "code": "AAAAAAAAAAAAAAAA", + "user_type_id": cls.account_type_1.id, + }) + cls.sequence_1 = cls.env['ir.sequence'].create({ + "name": "Test Sequence 1", + }) + cls.journal_1 = cls.env['account.journal'].create({ + "name": "Test Journal 1", + "type": "bank", + "sequence_id": cls.sequence_1.id, + }) + cls.statement_1 = cls.env["account.bank.statement"].create({ + "name": "Test Bank Statement 1", + "journal_id": cls.journal_1.id, + }) + cls.account_move_1 = cls.env["account.move"].create({ + "name": "Test Account Move 1", + "journal_id": cls.journal_1.id, + }) + cls.account_move_line_1 = cls.env["account.move.line"].create({ + "move_id": cls.account_move_1.id, + "account_id": cls.account_1.id, + }) + line_obj = cls.env["account.bank.statement.line"] + cls.st_line_w_partner_not_reconciled = line_obj.create({ + "name": "Test Account Bank Statement 1", + "statement_id": cls.statement_1.id, + "partner_id": cls.partner_1.id, + "journal_entry_ids": False, + "account_id": False, + }) + cls.st_line_wo_partner_not_reconciled = line_obj.create({ + "name": "Test Account Bank Statement 2", + "statement_id": cls.statement_1.id, + "partner_id": False, + "journal_entry_ids": False, + "account_id": False, + }) + cls.st_line_w_partner_reconciled = line_obj.create({ + "name": "Test Account Bank Statement 3", + "statement_id": cls.statement_1.id, + "partner_id": cls.partner_2.id, + }) + cls.account_move_line_1.write({ + "statement_line_id": cls.st_line_w_partner_reconciled.id, + }) + + def test_bank_statements_clear_partner(self): + self.statement_1.clear_partners() + # Confirm statement_line_1 has no parter + self.assertFalse( + self.st_line_w_partner_not_reconciled.partner_id + ) + # Confirm statement_line_3 still has partner because it was already reconciled + self.assertTrue( + self.st_line_w_partner_reconciled.partner_id + ) diff --git a/account_bank_statement_clear_partner/views/account_bank_statement_views.xml b/account_bank_statement_clear_partner/views/account_bank_statement_views.xml new file mode 100644 index 0000000..a70ace7 --- /dev/null +++ b/account_bank_statement_clear_partner/views/account_bank_statement_views.xml @@ -0,0 +1,15 @@ + + + + + + account.bank.statement + + + + + +