diff --git a/account_move_force_removal/README.rst b/account_move_force_removal/README.rst new file mode 100644 index 000000000..9c092d489 --- /dev/null +++ b/account_move_force_removal/README.rst @@ -0,0 +1,86 @@ +========================== +Account Move Force Removal +========================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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--financial--tools-lightgray.png?logo=github + :target: https://github.com/OCA/account-financial-tools/tree/14.0/account_move_force_removal + :alt: OCA/account-financial-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-financial-tools-14-0/account-financial-tools-14-0-account_move_force_removal + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/92/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows you to delete account moves, which is prevented in Odoo by default. +You must care yourself about the numbering sequence doing this. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Go to Invoicing > Customers > Invoices and enter an invoice. +#. Click on "Reset to draft" +#. Click on "Cancel entry +#. Try to delete invoice + +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 `_: + + * Víctor Martínez + * Pedro M. Baeza +* Alex Comba + +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-financial-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_move_force_removal/__init__.py b/account_move_force_removal/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/account_move_force_removal/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_move_force_removal/__manifest__.py b/account_move_force_removal/__manifest__.py new file mode 100644 index 000000000..e22d58473 --- /dev/null +++ b/account_move_force_removal/__manifest__.py @@ -0,0 +1,13 @@ +# Copyright 2020 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +{ + "name": "Account Move Force Removal", + "summary": """Allow force removal account moves""", + "version": "15.0.1.0.0", + "category": "Account", + "license": "AGPL-3", + "website": "https://github.com/OCA/account-financial-tools", + "author": "Tecnativa, Odoo Community Association (OCA)", + "depends": ["account"], +} diff --git a/account_move_force_removal/i18n/account_move_force_removal.pot b/account_move_force_removal/i18n/account_move_force_removal.pot new file mode 100644 index 000000000..a59147812 --- /dev/null +++ b/account_move_force_removal/i18n/account_move_force_removal.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_move_force_removal +# +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_force_removal +#: model:ir.model.fields,field_description:account_move_force_removal.field_account_move__display_name +msgid "Display Name" +msgstr "" + +#. module: account_move_force_removal +#: model:ir.model.fields,field_description:account_move_force_removal.field_account_move__id +msgid "ID" +msgstr "" + +#. module: account_move_force_removal +#: model:ir.model,name:account_move_force_removal.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: account_move_force_removal +#: model:ir.model.fields,field_description:account_move_force_removal.field_account_move____last_update +msgid "Last Modified on" +msgstr "" diff --git a/account_move_force_removal/models/__init__.py b/account_move_force_removal/models/__init__.py new file mode 100644 index 000000000..3bd27c056 --- /dev/null +++ b/account_move_force_removal/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html + +from . import account_move diff --git a/account_move_force_removal/models/account_move.py b/account_move_force_removal/models/account_move.py new file mode 100644 index 000000000..9a70e7492 --- /dev/null +++ b/account_move_force_removal/models/account_move.py @@ -0,0 +1,13 @@ +# Copyright 2020 Tecnativa - Víctor Martínez +# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html + +from odoo import models + + +class AccountMove(models.Model): + _inherit = "account.move" + + def unlink(self): + cancelled_moves = self.filtered(lambda m: m.state == "cancel") + super(AccountMove, cancelled_moves.with_context(force_delete=True)).unlink() + return super(AccountMove, self - cancelled_moves).unlink() diff --git a/account_move_force_removal/readme/CONTRIBUTORS.rst b/account_move_force_removal/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..f6525642a --- /dev/null +++ b/account_move_force_removal/readme/CONTRIBUTORS.rst @@ -0,0 +1,9 @@ +* `Tecnativa `_: + + * Víctor Martínez + * Pedro M. Baeza +* Alex Comba + +* `Sygel `__: + + * Ángel García de la Chica Herrera diff --git a/account_move_force_removal/readme/DESCRIPTION.rst b/account_move_force_removal/readme/DESCRIPTION.rst new file mode 100644 index 000000000..5f0c79047 --- /dev/null +++ b/account_move_force_removal/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module allows you to delete account moves, which is prevented in Odoo by default. +You must care yourself about the numbering sequence doing this. diff --git a/account_move_force_removal/readme/USAGE.rst b/account_move_force_removal/readme/USAGE.rst new file mode 100644 index 000000000..6d501c3ca --- /dev/null +++ b/account_move_force_removal/readme/USAGE.rst @@ -0,0 +1,4 @@ +#. Go to Invoicing > Customers > Invoices and enter an invoice. +#. Click on "Reset to draft" +#. Click on "Cancel entry +#. Try to delete invoice diff --git a/account_move_force_removal/static/description/icon.png b/account_move_force_removal/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_move_force_removal/static/description/icon.png differ diff --git a/account_move_force_removal/static/description/index.html b/account_move_force_removal/static/description/index.html new file mode 100644 index 000000000..2143a227b --- /dev/null +++ b/account_move_force_removal/static/description/index.html @@ -0,0 +1,435 @@ + + + + + + +Account Move Force Removal + + + +
+

Account Move Force Removal

+ + +

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

+

This module allows you to delete account moves, which is prevented in Odoo by default. +You must care yourself about the numbering sequence doing this.

+

Table of contents

+ +
+

Usage

+
    +
  1. Go to Invoicing > Customers > Invoices and enter an invoice.
  2. +
  3. Click on “Reset to draft”
  4. +
  5. Click on “Cancel entry
  6. +
  7. Try to delete invoice
  8. +
+
+
+

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

+ +
+
+

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-financial-tools project on GitHub.

+

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

+
+
+
+ + diff --git a/account_move_force_removal/tests/__init__.py b/account_move_force_removal/tests/__init__.py new file mode 100644 index 000000000..a7aa32c01 --- /dev/null +++ b/account_move_force_removal/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2020 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from . import test_move diff --git a/account_move_force_removal/tests/test_move.py b/account_move_force_removal/tests/test_move.py new file mode 100644 index 000000000..73b5a8bee --- /dev/null +++ b/account_move_force_removal/tests/test_move.py @@ -0,0 +1,63 @@ +# Copyright 2020 Tecnativa - Víctor Martínez +# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html + +from odoo.exceptions import UserError +from odoo.tests import Form +from odoo.tests.common import TransactionCase + + +class TestMove(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner = cls.env["res.partner"].create( + {"name": "Test customer", "customer_rank": 1} + ) + cls.journal = cls.env["account.journal"].create( + { + "name": "Test journal", + "type": "sale", + "code": "test-sale-jorunal", + "company_id": cls.env.company.id, + } + ) + cls.product = cls.env["product.product"].create( + {"name": "Test product", "type": "service"} + ) + cls.company = cls.env.company + account_type = cls.env.ref("account.data_account_type_other_income") + cls.income_account = cls.env["account.account"].search( + [ + ("user_type_id", "=", account_type.id), + ("company_id", "=", cls.company.id), + ], + limit=1, + ) + + invoice = Form( + cls.env["account.move"].with_context( + default_type="out_invoice", default_company_id=cls.env.company.id + ) + ) + invoice.partner_id = cls.partner + invoice.journal_id = cls.journal + with invoice.invoice_line_ids.new() as line_form: + line_form.name = cls.product.name + line_form.product_id = cls.product + line_form.quantity = 1.0 + line_form.price_unit = 10 + line_form.account_id = cls.income_account + invoice = invoice.save() + invoice.action_post() + cls.invoice = invoice + + def test_remove_invoice_error(self): + # Delete invoice while name isn't / + with self.assertRaises(UserError): + self.invoice.unlink() + + def test_ok_invoice_error(self): + # Delete invoice (previously draft + camcel) + self.invoice.button_draft() + self.invoice.button_cancel() + self.invoice.unlink() diff --git a/setup/account_move_force_removal/odoo/addons/account_move_force_removal b/setup/account_move_force_removal/odoo/addons/account_move_force_removal new file mode 120000 index 000000000..c240a17f3 --- /dev/null +++ b/setup/account_move_force_removal/odoo/addons/account_move_force_removal @@ -0,0 +1 @@ +../../../../account_move_force_removal \ No newline at end of file diff --git a/setup/account_move_force_removal/setup.py b/setup/account_move_force_removal/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/account_move_force_removal/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)