diff --git a/sale_line_refund_to_invoice_qty/README.rst b/sale_line_refund_to_invoice_qty/README.rst new file mode 100644 index 00000000000..6b832cca4db --- /dev/null +++ b/sale_line_refund_to_invoice_qty/README.rst @@ -0,0 +1,88 @@ +=============================== +Sale Line Refund To Invoice Qty +=============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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-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/15.0/sale_line_refund_to_invoice_qty + :alt: OCA/account-invoicing +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-invoicing-15-0/account-invoicing-15-0-sale_line_refund_to_invoice_qty + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/95/15.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows the user to choose whether refunded quantities in credit +notes should be considered as quantities to be reinvoiced in the related sales, +thus deciding if they should be added or not to the quantity to invoice of the +related sales order line. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +When creating a credit note from an invoice, you can mark the checkbox "Not +reinvoice refunded quantity" to prevent the refunded quantities to be deducted +from the quantity invoiced of the related sales order lines. + +Furthermore, after creating the credit note, you can mark the field "Sale qty +not to reinvoice" to decide the criteria to be used for each specific invoice +line. + +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 +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Jordi Masvidal +* Lois Rilo + +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-invoicing `_ 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/__init__.py b/sale_line_refund_to_invoice_qty/__init__.py new file mode 100644 index 00000000000..433b1e1ff4a --- /dev/null +++ b/sale_line_refund_to_invoice_qty/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2021 ForgeFlow (http://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from . import models +from . import wizards diff --git a/sale_line_refund_to_invoice_qty/__manifest__.py b/sale_line_refund_to_invoice_qty/__manifest__.py new file mode 100644 index 00000000000..66aa858d0ae --- /dev/null +++ b/sale_line_refund_to_invoice_qty/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2021 ForgeFlow (http://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +{ + "name": "Sale Line Refund To Invoice Qty", + "summary": """Allow deciding whether refunded quantity should be considered + as quantity to reinvoice""", + "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", + "views/sale_order_views.xml", + "wizards/account_move_reversal_view.xml", + ], +} diff --git a/sale_line_refund_to_invoice_qty/i18n/es.po b/sale_line_refund_to_invoice_qty/i18n/es.po new file mode 100644 index 00000000000..de1c4bc3204 --- /dev/null +++ b/sale_line_refund_to_invoice_qty/i18n/es.po @@ -0,0 +1,70 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_line_refund_to_invoice_qty +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.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: sale_line_refund_to_invoice_qty +#: model:ir.model,name:sale_line_refund_to_invoice_qty.model_account_move_reversal +msgid "Account Move Reversal" +msgstr "Reversión de asiento contable" + +#. module: sale_line_refund_to_invoice_qty +#: model:ir.model,name:sale_line_refund_to_invoice_qty.model_account_move +msgid "Journal Entry" +msgstr "Asiento contable" + +#. module: sale_line_refund_to_invoice_qty +#: model:ir.model,name:sale_line_refund_to_invoice_qty.model_account_move_line +msgid "Journal Item" +msgstr "Apunte contable" + +#. module: sale_line_refund_to_invoice_qty +#: model:ir.model.fields,help:sale_line_refund_to_invoice_qty.field_account_move_line__sale_qty_to_reinvoice +msgid "Leave it marked if you will reinvoice the same sale order line" +msgstr "Déjelo marcado si va a volver a facturar la misma línea de pedido de venta" + +#. module: sale_line_refund_to_invoice_qty +#: model:ir.model.fields,help:sale_line_refund_to_invoice_qty.field_account_move_reversal__sale_qty_to_reinvoice +msgid "" +"Leave it marked if you will reinvoice the same sale order line (standard " +"behaviour)" +msgstr "Déjelo marcado si va a volver a facturar la misma línea de pedido de venta " +"(comportamiento estándar)" + +#. module: sale_line_refund_to_invoice_qty +#: model_terms:ir.ui.view,arch_db:sale_line_refund_to_invoice_qty.view_account_move_reversal +msgid "" +"Leave it marked when other customer invoices are expected for the quantities" +" in the credit note." +msgstr "Déjelo marcado cuando se esperen otras facturas de clientes por las " +"cantidades de la factura rectificativa." + +#. module: sale_line_refund_to_invoice_qty +#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_sale_order_line__qty_refunded_not_invoiceable +msgid "Quantity Refunded Not Invoiceable" +msgstr "Cantidad reembolsada no facturable" + +#. module: sale_line_refund_to_invoice_qty +#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_line__sale_qty_to_reinvoice +msgid "Sale Qty To Reinvoice" +msgstr "Cantidad de venta a refacturar" + +#. module: sale_line_refund_to_invoice_qty +#: model:ir.model,name:sale_line_refund_to_invoice_qty.model_sale_order_line +msgid "Sales Order Line" +msgstr "Línea de pedido de venta" + +#. module: sale_line_refund_to_invoice_qty +#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_reversal__sale_qty_to_reinvoice +msgid "This credit note will be reinvoiced" +msgstr "Esta factura rectificativa será refacturada" diff --git a/sale_line_refund_to_invoice_qty/i18n/sale_line_refund_to_invoice_qty.pot b/sale_line_refund_to_invoice_qty/i18n/sale_line_refund_to_invoice_qty.pot new file mode 100644 index 00000000000..844d879d8cd --- /dev/null +++ b/sale_line_refund_to_invoice_qty/i18n/sale_line_refund_to_invoice_qty.pot @@ -0,0 +1,68 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_line_refund_to_invoice_qty +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.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: sale_line_refund_to_invoice_qty +#: model:ir.model,name:sale_line_refund_to_invoice_qty.model_account_move_reversal +msgid "Account Move Reversal" +msgstr "" + +#. module: sale_line_refund_to_invoice_qty +#: model:ir.model,name:sale_line_refund_to_invoice_qty.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: sale_line_refund_to_invoice_qty +#: model:ir.model,name:sale_line_refund_to_invoice_qty.model_account_move_line +msgid "Journal Item" +msgstr "" + +#. module: sale_line_refund_to_invoice_qty +#: model:ir.model.fields,help:sale_line_refund_to_invoice_qty.field_account_move_line__sale_qty_to_reinvoice +msgid "Leave it marked if you will reinvoice the same sale order line" +msgstr "" + +#. module: sale_line_refund_to_invoice_qty +#: model:ir.model.fields,help:sale_line_refund_to_invoice_qty.field_account_move_reversal__sale_qty_to_reinvoice +msgid "" +"Leave it marked if you will reinvoice the same sale order line (standard " +"behaviour)" +msgstr "" + +#. module: sale_line_refund_to_invoice_qty +#: model_terms:ir.ui.view,arch_db:sale_line_refund_to_invoice_qty.view_account_move_reversal +msgid "" +"Leave it marked when other customer invoices are expected for the quantities" +" in the credit note." +msgstr "" + +#. module: sale_line_refund_to_invoice_qty +#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_sale_order_line__qty_refunded_not_invoiceable +msgid "Quantity Refunded Not Invoiceable" +msgstr "" + +#. module: sale_line_refund_to_invoice_qty +#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_line__sale_qty_to_reinvoice +msgid "Sale Qty To Reinvoice" +msgstr "" + +#. module: sale_line_refund_to_invoice_qty +#: model:ir.model,name:sale_line_refund_to_invoice_qty.model_sale_order_line +msgid "Sales Order Line" +msgstr "" + +#. module: sale_line_refund_to_invoice_qty +#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_reversal__sale_qty_to_reinvoice +msgid "This credit note will be reinvoiced" +msgstr "" diff --git a/sale_line_refund_to_invoice_qty/models/__init__.py b/sale_line_refund_to_invoice_qty/models/__init__.py new file mode 100644 index 00000000000..b4076239b62 --- /dev/null +++ b/sale_line_refund_to_invoice_qty/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2021 ForgeFlow (http://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from . import account +from . import sale diff --git a/sale_line_refund_to_invoice_qty/models/account.py b/sale_line_refund_to_invoice_qty/models/account.py new file mode 100644 index 00000000000..061ad0b2a7f --- /dev/null +++ b/sale_line_refund_to_invoice_qty/models/account.py @@ -0,0 +1,26 @@ +# Copyright 2021 ForgeFlow (http://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from odoo import api, fields, models + + +class AccountMove(models.Model): + _inherit = "account.move" + + @api.returns("self", lambda value: value.id) + def copy(self, default=None): + # Set the sale_qty_to_reinvoice based on the boolean from the + # reversal wizard + res = super().copy(default=default) + sale_qty_to_reinvoice = self.env.context.get("sale_qty_to_reinvoice", False) + res.line_ids.write({"sale_qty_to_reinvoice": sale_qty_to_reinvoice}) + return res + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + sale_qty_to_reinvoice = fields.Boolean( + default=True, + help="Leave it marked if you will reinvoice the same sale order line", + copy=False, + ) diff --git a/sale_line_refund_to_invoice_qty/models/sale.py b/sale_line_refund_to_invoice_qty/models/sale.py new file mode 100644 index 00000000000..7624d257423 --- /dev/null +++ b/sale_line_refund_to_invoice_qty/models/sale.py @@ -0,0 +1,58 @@ +# Copyright 2021 ForgeFlow (http://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from odoo import api, fields, models + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + qty_refunded_not_invoiceable = fields.Float( + compute="_compute_qty_refunded_not_invoiceable", + string="Quantity Refunded Not Invoiceable", + digits="Product Unit of Measure", + ) + + @api.depends( + "invoice_lines.move_id.state", + "invoice_lines.quantity", + "untaxed_amount_to_invoice", + "invoice_lines.sale_qty_to_reinvoice", + ) + def _compute_qty_invoiced(self): + res = super()._compute_qty_invoiced() + # Revert effect of refunds in invoice_qty when `sale_qty_to_reinvoice` + # is not set. + for line in self: + qty_invoiced = line.qty_invoiced + for invoice_line in line.invoice_lines: + if ( + invoice_line.move_id.state != "cancel" + and invoice_line.move_id.move_type == "out_refund" + and not invoice_line.sale_qty_to_reinvoice + ): + qty_invoiced += invoice_line.product_uom_id._compute_quantity( + invoice_line.quantity, line.product_uom + ) + if line.qty_invoiced != qty_invoiced: + line.qty_invoiced = qty_invoiced + return res + + @api.depends( + "product_uom_qty", + "invoice_lines.move_id.state", + "invoice_lines.quantity", + "invoice_lines.sale_qty_to_reinvoice", + ) + def _compute_qty_refunded_not_invoiceable(self): + for line in self: + qty_ref_not_inv = 0.0 + for invoice_line in line.invoice_lines: + if ( + invoice_line.move_id.state != "cancel" + and invoice_line.move_id.move_type == "out_refund" + and not invoice_line.sale_qty_to_reinvoice + ): + qty_ref_not_inv += invoice_line.product_uom_id._compute_quantity( + invoice_line.quantity, line.product_uom + ) + line.qty_refunded_not_invoiceable = qty_ref_not_inv diff --git a/sale_line_refund_to_invoice_qty/readme/CONTRIBUTORS.rst b/sale_line_refund_to_invoice_qty/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..90dd6c9906b --- /dev/null +++ b/sale_line_refund_to_invoice_qty/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Jordi Masvidal +* Lois Rilo diff --git a/sale_line_refund_to_invoice_qty/readme/DESCRIPTION.rst b/sale_line_refund_to_invoice_qty/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..0e106be587a --- /dev/null +++ b/sale_line_refund_to_invoice_qty/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +This module allows the user to choose whether refunded quantities in credit +notes should be considered as quantities to be reinvoiced in the related sales, +thus deciding if they should be added or not to the quantity to invoice of the +related sales order line. diff --git a/sale_line_refund_to_invoice_qty/readme/USAGE.rst b/sale_line_refund_to_invoice_qty/readme/USAGE.rst new file mode 100644 index 00000000000..615b3bb3497 --- /dev/null +++ b/sale_line_refund_to_invoice_qty/readme/USAGE.rst @@ -0,0 +1,7 @@ +When creating a credit note from an invoice, you can mark the checkbox "Not +reinvoice refunded quantity" to prevent the refunded quantities to be deducted +from the quantity invoiced of the related sales order lines. + +Furthermore, after creating the credit note, you can mark the field "Sale qty +not to reinvoice" to decide the criteria to be used for each specific invoice +line. diff --git a/sale_line_refund_to_invoice_qty/static/description/icon.png b/sale_line_refund_to_invoice_qty/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/sale_line_refund_to_invoice_qty/static/description/icon.png differ diff --git a/sale_line_refund_to_invoice_qty/static/description/index.html b/sale_line_refund_to_invoice_qty/static/description/index.html new file mode 100644 index 00000000000..95fb65c47f8 --- /dev/null +++ b/sale_line_refund_to_invoice_qty/static/description/index.html @@ -0,0 +1,433 @@ + + + + + + +Sale Line Refund To Invoice Qty + + + +
+

Sale Line Refund To Invoice Qty

+ + +

Beta License: LGPL-3 OCA/account-invoicing Translate me on Weblate Try me on Runbot

+

This module allows the user to choose whether refunded quantities in credit +notes should be considered as quantities to be reinvoiced in the related sales, +thus deciding if they should be added or not to the quantity to invoice of the +related sales order line.

+

Table of contents

+ +
+

Usage

+

When creating a credit note from an invoice, you can mark the checkbox “Not +reinvoice refunded quantity” to prevent the refunded quantities to be deducted +from the quantity invoiced of the related sales order lines.

+

Furthermore, after creating the credit note, you can mark the field “Sale qty +not to reinvoice” to decide the criteria to be used for each specific invoice +line.

+
+
+

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

+
    +
  • ForgeFlow
  • +
+
+ +
+

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-invoicing 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/tests/__init__.py b/sale_line_refund_to_invoice_qty/tests/__init__.py new file mode 100644 index 00000000000..ed4bbd50853 --- /dev/null +++ b/sale_line_refund_to_invoice_qty/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2021 ForgeFlow (http://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from . import test_sale_line_refund_to_invoice_qty diff --git a/sale_line_refund_to_invoice_qty/tests/test_sale_line_refund_to_invoice_qty.py b/sale_line_refund_to_invoice_qty/tests/test_sale_line_refund_to_invoice_qty.py new file mode 100644 index 00000000000..aa082853bc5 --- /dev/null +++ b/sale_line_refund_to_invoice_qty/tests/test_sale_line_refund_to_invoice_qty.py @@ -0,0 +1,79 @@ +# Copyright 2021 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 TestSaleLineRefundToInvoiceQty(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_refund_qty_not_to_reinvoice(self): + """ + Test that the quantities refunded are not considered as quantities to + reinvoice in the sales order line, when the boolean is checked. + """ + self.assertEqual(self.order.order_line[0].qty_invoiced, 5.0) + reversal_wizard = self.move_reversal_wiz(self.invoice) + reversal_wizard.write({"sale_qty_to_reinvoice": False}) + credit_note = self.env["account.move"].browse( + reversal_wizard.reverse_moves()["res_id"] + ) + for line in credit_note.line_ids: + self.assertFalse(line.sale_qty_to_reinvoice) + self.assertEqual(self.order.order_line[0].qty_invoiced, 5.0) + self.assertEqual(self.order.order_line[0].qty_to_invoice, 0.0) + self.assertEqual(self.order.order_line[0].qty_refunded_not_invoiceable, 5.0) + + def test_refund_qty_to_reinvoice(self): + """ + Test that the quantities refunded are considered as quantities to + reinvoice in the sales order line, when the boolean is left unchecked. + """ + 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"] + ) + for line in credit_note.line_ids: + self.assertTrue(line.sale_qty_to_reinvoice) + self.assertEqual(self.order.order_line[0].qty_invoiced, 0.0) + self.assertEqual(self.order.order_line[0].qty_to_invoice, 5.0) + self.assertEqual(self.order.order_line[0].qty_refunded_not_invoiceable, 0.0) diff --git a/sale_line_refund_to_invoice_qty/views/account_move_views.xml b/sale_line_refund_to_invoice_qty/views/account_move_views.xml new file mode 100644 index 00000000000..9a730d8e86f --- /dev/null +++ b/sale_line_refund_to_invoice_qty/views/account_move_views.xml @@ -0,0 +1,19 @@ + + + + + account.move.form.inherit + account.move + + + + + + + + diff --git a/sale_line_refund_to_invoice_qty/views/sale_order_views.xml b/sale_line_refund_to_invoice_qty/views/sale_order_views.xml new file mode 100644 index 00000000000..0eec39e24ba --- /dev/null +++ b/sale_line_refund_to_invoice_qty/views/sale_order_views.xml @@ -0,0 +1,15 @@ + + + + + sale.order.form.inherit + sale.order + + + + + + + + diff --git a/sale_line_refund_to_invoice_qty/wizards/__init__.py b/sale_line_refund_to_invoice_qty/wizards/__init__.py new file mode 100644 index 00000000000..17ca4ac5dfc --- /dev/null +++ b/sale_line_refund_to_invoice_qty/wizards/__init__.py @@ -0,0 +1,3 @@ +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from . import account_move_reversal diff --git a/sale_line_refund_to_invoice_qty/wizards/account_move_reversal.py b/sale_line_refund_to_invoice_qty/wizards/account_move_reversal.py new file mode 100644 index 00000000000..4fbcc03e59f --- /dev/null +++ b/sale_line_refund_to_invoice_qty/wizards/account_move_reversal.py @@ -0,0 +1,23 @@ +# Copyright 2021 ForgeFlow (http://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from odoo import fields, models + + +class AccountMoveReversal(models.TransientModel): + _inherit = "account.move.reversal" + + sale_qty_to_reinvoice = fields.Boolean( + string="This credit note will be reinvoiced", + default="True", + help="Leave it marked if you will reinvoice the same sale order line " + "(standard behaviour)", + ) + + def reverse_moves(self): + sale_qty_to_reinvoice = ( + True if self.refund_method == "modify" else self.sale_qty_to_reinvoice + ) + return super( + AccountMoveReversal, + self.with_context(sale_qty_to_reinvoice=sale_qty_to_reinvoice), + ).reverse_moves() diff --git a/sale_line_refund_to_invoice_qty/wizards/account_move_reversal_view.xml b/sale_line_refund_to_invoice_qty/wizards/account_move_reversal_view.xml new file mode 100644 index 00000000000..e4eec4b8738 --- /dev/null +++ b/sale_line_refund_to_invoice_qty/wizards/account_move_reversal_view.xml @@ -0,0 +1,21 @@ + + + + account.move.reversal.form.inherit + account.move.reversal + + + + + +
+ Leave it marked when other customer invoices are expected for the quantities in the credit note. +
+
+
+
+
+
diff --git a/setup/sale_line_refund_to_invoice_qty/odoo/addons/sale_line_refund_to_invoice_qty b/setup/sale_line_refund_to_invoice_qty/odoo/addons/sale_line_refund_to_invoice_qty new file mode 120000 index 00000000000..1a65e6f4880 --- /dev/null +++ b/setup/sale_line_refund_to_invoice_qty/odoo/addons/sale_line_refund_to_invoice_qty @@ -0,0 +1 @@ +../../../../sale_line_refund_to_invoice_qty \ No newline at end of file diff --git a/setup/sale_line_refund_to_invoice_qty/setup.py b/setup/sale_line_refund_to_invoice_qty/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/sale_line_refund_to_invoice_qty/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)