Skip to content

Commit

Permalink
[ADD] sale_credit_note_reversal: module to create reversals from sale…
Browse files Browse the repository at this point in the history
… credit notes
  • Loading branch information
AaronHForgeFlow committed Oct 4, 2024
1 parent 82e7d5c commit 4a312c7
Show file tree
Hide file tree
Showing 15 changed files with 672 additions and 0 deletions.
92 changes: 92 additions & 0 deletions sale_credit_note_reversal/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/sale-workflow/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 <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_credit_note_reversal%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* ForgeFlow

Contributors
~~~~~~~~~~~~

* Aaron Henriquez <[email protected]>

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 <https://github.com/OCA/sale-workflow/tree/16.0/sale_credit_note_reversal>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sale_credit_note_reversal/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions sale_credit_note_reversal/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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",
],
}
1 change: 1 addition & 0 deletions sale_credit_note_reversal/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_move
17 changes: 17 additions & 0 deletions sale_credit_note_reversal/models/account_move.py
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions sale_credit_note_reversal/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Aaron Henriquez <[email protected]>
9 changes: 9 additions & 0 deletions sale_credit_note_reversal/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions sale_credit_note_reversal/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4a312c7

Please sign in to comment.