diff --git a/sale_credit_note_reversal/README.rst b/sale_credit_note_reversal/README.rst new file mode 100644 index 00000000000..59e009290cf --- /dev/null +++ b/sale_credit_note_reversal/README.rst @@ -0,0 +1,92 @@ +========================= +Sale Credit Note Reversal +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:eab5eda60c42c708170189a12a4d56f765a5fcfd133350ec0df2f01abfa598a1 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/sale-workflow/tree/16.0/sale_credit_note_reversal + :alt: OCA/sale-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_credit_note_reversal + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Allow to revert a credit note. Standard Odoo does not allow it. +When reverting the credit note form the journal entry Standard Odoo +does not link it to the Sales order, because the reversal is not an +invoice. + +This also serves when the posting credit notes by mistake. For example, +when adding a negative quantity in the sale line and creating Odoo will +actually create a credit note, then, if other lines with positive quantites +are added nothing changes, and the invoice will be still a credit note. + +**Table of contents** + +.. contents:: + :local: + +Known issues / Roadmap +====================== + +An integration with sale_line_refund_to_invoice_qty module will be very useful. +The reverted credit note does not add quantity to the qty_invoiced. The credit +note does also not update the qty_to_invoice in the normal case, so at least +this reversal is consistent. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Aaron Henriquez + +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/sale-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_credit_note_reversal/__init__.py b/sale_credit_note_reversal/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/sale_credit_note_reversal/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_credit_note_reversal/__manifest__.py b/sale_credit_note_reversal/__manifest__.py new file mode 100644 index 00000000000..dd5fdb49ff8 --- /dev/null +++ b/sale_credit_note_reversal/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2024 ForgeFlow (http://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +{ + "name": "Sale Credit Note Reversal", + "summary": """Allow to revert a credit note""", + "version": "16.0.1.0.0", + "category": "Sales", + "website": "https://github.com/OCA/account-invoicing", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "license": "LGPL-3", + "application": False, + "installable": True, + "depends": ["sale_management"], + "data": [ + "views/account_move_views.xml", + ], +} diff --git a/sale_credit_note_reversal/models/__init__.py b/sale_credit_note_reversal/models/__init__.py new file mode 100644 index 00000000000..9c0a4213854 --- /dev/null +++ b/sale_credit_note_reversal/models/__init__.py @@ -0,0 +1 @@ +from . import account_move diff --git a/sale_credit_note_reversal/models/account_move.py b/sale_credit_note_reversal/models/account_move.py new file mode 100644 index 00000000000..6d064b32f43 --- /dev/null +++ b/sale_credit_note_reversal/models/account_move.py @@ -0,0 +1,17 @@ +# Copyright 2024 ForgeFlow (http://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from odoo import models + + +class AccountMove(models.Model): + _inherit = "account.move" + + def _reverse_moves(self, default_values_list=None, cancel=False): + reversed_moves = super()._reverse_moves( + default_values_list=default_values_list, cancel=cancel + ) + for move in reversed_moves: + if move.reversed_entry_id.move_type == "out_refund": + # convert from entry to out_invoice + move.move_type = "out_invoice" + return reversed_moves diff --git a/sale_credit_note_reversal/readme/CONTRIBUTORS.rst b/sale_credit_note_reversal/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..9fa71265b47 --- /dev/null +++ b/sale_credit_note_reversal/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Aaron Henriquez diff --git a/sale_credit_note_reversal/readme/DESCRIPTION.rst b/sale_credit_note_reversal/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..219a169ac49 --- /dev/null +++ b/sale_credit_note_reversal/readme/DESCRIPTION.rst @@ -0,0 +1,9 @@ +Allow to revert a credit note. Standard Odoo does not allow it. +When reverting the credit note form the journal entry Standard Odoo +does not link it to the Sales order, because the reversal is not an +invoice. + +This also serves when the posting credit notes by mistake. For example, +when adding a negative quantity in the sale line and creating Odoo will +actually create a credit note, then, if other lines with positive quantites +are added nothing changes, and the invoice will be still a credit note. diff --git a/sale_credit_note_reversal/readme/ROADMAP.rst b/sale_credit_note_reversal/readme/ROADMAP.rst new file mode 100644 index 00000000000..a114282d7db --- /dev/null +++ b/sale_credit_note_reversal/readme/ROADMAP.rst @@ -0,0 +1,4 @@ +An integration with sale_line_refund_to_invoice_qty module will be very useful. +The reverted credit note does not add quantity to the qty_invoiced. The credit +note does also not update the qty_to_invoice in the normal case, so at least +this reversal is consistent. diff --git a/sale_credit_note_reversal/static/description/icon.png b/sale_credit_note_reversal/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/sale_credit_note_reversal/static/description/icon.png differ diff --git a/sale_credit_note_reversal/static/description/index.html b/sale_credit_note_reversal/static/description/index.html new file mode 100644 index 00000000000..603755540ae --- /dev/null +++ b/sale_credit_note_reversal/static/description/index.html @@ -0,0 +1,436 @@ + + + + + + +Sale Credit Note Reversal + + + +
+

Sale Credit Note Reversal

+ + +

Beta License: LGPL-3 OCA/sale-workflow Translate me on Weblate Try me on Runboat

+

Allow to revert a credit note. Standard Odoo does not allow it. +When reverting the credit note form the journal entry Standard Odoo +does not link it to the Sales order, because the reversal is not an +invoice.

+

This also serves when the posting credit notes by mistake. For example, +when adding a negative quantity in the sale line and creating Odoo will +actually create a credit note, then, if other lines with positive quantites +are added nothing changes, and the invoice will be still a credit note.

+

Table of contents

+ +
+

Known issues / Roadmap

+

An integration with sale_line_refund_to_invoice_qty module will be very useful. +The reverted credit note does not add quantity to the qty_invoiced. The credit +note does also not update the qty_to_invoice in the normal case, so at least +this reversal is consistent.

+
+
+

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 to smash 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/sale-workflow project on GitHub.

+

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

+
+
+
+ + diff --git a/sale_credit_note_reversal/tests/__init__.py b/sale_credit_note_reversal/tests/__init__.py new file mode 100644 index 00000000000..d634cf64869 --- /dev/null +++ b/sale_credit_note_reversal/tests/__init__.py @@ -0,0 +1 @@ +from . import test_sale_credit_note_reversal diff --git a/sale_credit_note_reversal/tests/test_sale_credit_note_reversal.py b/sale_credit_note_reversal/tests/test_sale_credit_note_reversal.py new file mode 100644 index 00000000000..4831d2f0769 --- /dev/null +++ b/sale_credit_note_reversal/tests/test_sale_credit_note_reversal.py @@ -0,0 +1,65 @@ +# Copyright 2024 ForgeFlow (http://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from odoo.tests.common import TransactionCase, tagged + + +@tagged("post_install", "-at_install") +class TestSaleCreditNoteReversal(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner = cls.env["res.partner"].create({"name": "Test"}) + cls.product = cls.env["product.product"].create( + {"name": "test_product", "type": "consu"} + ) + cls.order = cls.env["sale.order"].create( + { + "partner_id": cls.partner.id, + "order_line": [ + ( + 0, + 0, + { + "name": cls.product.name, + "product_id": cls.product.id, + "product_uom_qty": 5, + "product_uom": cls.product.uom_id.id, + "price_unit": 1000.00, + }, + ), + ], + "pricelist_id": cls.env.ref("product.list0").id, + } + ) + cls.order.action_confirm() + cls.order.order_line[0].write({"qty_delivered": 5.0}) + cls.order._create_invoices() + cls.invoice = cls.order.invoice_ids[0] + cls.invoice.action_post() + + def move_reversal_wiz(self, move): + wizard = ( + self.env["account.move.reversal"] + .with_context(active_model="account.move", active_ids=[move.id]) + .create({"journal_id": move.journal_id.id}) + ) + return wizard + + def test_reversal_linked_to_order(self): + """ + Revert the credit note and check the it is linked to the sales order. + """ + self.assertEqual(self.order.order_line[0].qty_invoiced, 5.0) + reversal_wizard = self.move_reversal_wiz(self.invoice) + credit_note = self.env["account.move"].browse( + reversal_wizard.reverse_moves()["res_id"] + ) + credit_note.action_post() + self.assertEqual(self.order.order_line[0].qty_invoiced, 0.0) + second_reversal_wizard = self.move_reversal_wiz(credit_note) + second_invoice = self.env["account.move"].browse( + second_reversal_wizard.reverse_moves()["res_id"] + ) + second_invoice.action_post() + self.assertEqual(len(self.order.invoice_ids), 3.0) + self.assertEqual(self.order.order_line[0].qty_invoiced, 5.0) diff --git a/sale_credit_note_reversal/views/account_move_views.xml b/sale_credit_note_reversal/views/account_move_views.xml new file mode 100644 index 00000000000..268237be4e7 --- /dev/null +++ b/sale_credit_note_reversal/views/account_move_views.xml @@ -0,0 +1,21 @@ + + + + + account.move.credit.note.reverse + account.move + + + + + + diff --git a/sale_line_refund_to_invoice_qty/README.rst b/sale_line_refund_to_invoice_qty/README.rst index 931a1ab6395..5c3086b73fc 100644 --- a/sale_line_refund_to_invoice_qty/README.rst +++ b/sale_line_refund_to_invoice_qty/README.rst @@ -16,14 +16,14 @@ Sale Line Refund To Invoice Qty .. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 -.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github - :target: https://github.com/OCA/account-invoicing/tree/16.0/sale_line_refund_to_invoice_qty - :alt: OCA/account-invoicing +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/sale-workflow/tree/16.0/sale_line_refund_to_invoice_qty + :alt: OCA/sale-workflow .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/account-invoicing-16-0/account-invoicing-16-0-sale_line_refund_to_invoice_qty + :target: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_line_refund_to_invoice_qty :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -52,10 +52,10 @@ line. Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. +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 to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -86,6 +86,6 @@ 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-invoicing `_ project on GitHub. +This module is part of the `OCA/sale-workflow `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_line_refund_to_invoice_qty/static/description/index.html b/sale_line_refund_to_invoice_qty/static/description/index.html index 923633f96d9..e2b977051ae 100644 --- a/sale_line_refund_to_invoice_qty/static/description/index.html +++ b/sale_line_refund_to_invoice_qty/static/description/index.html @@ -1,20 +1,20 @@ - + - + Sale Line Refund To Invoice Qty