From 9909ba60039e2438f284b9cca92fb55b6179d130 Mon Sep 17 00:00:00 2001
From: JordiMForgeFlow
Date: Tue, 22 Jun 2021 11:22:18 +0200
Subject: [PATCH 1/9] [ADD] sale_line_credit_note_invoiced_qty
---
sale_line_refund_to_invoice_qty/README.rst | 87 ++++
sale_line_refund_to_invoice_qty/__init__.py | 5 +
.../__manifest__.py | 20 +
.../i18n/sale_line_refund_to_invoice_qty.pot | 63 +++
.../models/__init__.py | 4 +
.../models/account.py | 28 ++
.../models/sale.py | 57 +++
.../readme/CONTRIBUTORS.rst | 1 +
.../readme/DESCRIPTION.rst | 4 +
.../readme/USAGE.rst | 7 +
.../static/description/icon.png | Bin 0 -> 9455 bytes
.../static/description/index.html | 432 ++++++++++++++++++
.../tests/__init__.py | 4 +
.../test_sale_line_refund_to_invoice_qty.py | 74 +++
.../views/account_move_views.xml | 21 +
.../views/sale_order_views.xml | 15 +
.../wizards/__init__.py | 3 +
.../wizards/account_move_reversal.py | 19 +
.../wizards/account_move_reversal_view.xml | 19 +
19 files changed, 863 insertions(+)
create mode 100644 sale_line_refund_to_invoice_qty/README.rst
create mode 100644 sale_line_refund_to_invoice_qty/__init__.py
create mode 100644 sale_line_refund_to_invoice_qty/__manifest__.py
create mode 100644 sale_line_refund_to_invoice_qty/i18n/sale_line_refund_to_invoice_qty.pot
create mode 100644 sale_line_refund_to_invoice_qty/models/__init__.py
create mode 100644 sale_line_refund_to_invoice_qty/models/account.py
create mode 100644 sale_line_refund_to_invoice_qty/models/sale.py
create mode 100644 sale_line_refund_to_invoice_qty/readme/CONTRIBUTORS.rst
create mode 100644 sale_line_refund_to_invoice_qty/readme/DESCRIPTION.rst
create mode 100644 sale_line_refund_to_invoice_qty/readme/USAGE.rst
create mode 100644 sale_line_refund_to_invoice_qty/static/description/icon.png
create mode 100644 sale_line_refund_to_invoice_qty/static/description/index.html
create mode 100644 sale_line_refund_to_invoice_qty/tests/__init__.py
create mode 100644 sale_line_refund_to_invoice_qty/tests/test_sale_line_refund_to_invoice_qty.py
create mode 100644 sale_line_refund_to_invoice_qty/views/account_move_views.xml
create mode 100644 sale_line_refund_to_invoice_qty/views/sale_order_views.xml
create mode 100644 sale_line_refund_to_invoice_qty/wizards/__init__.py
create mode 100644 sale_line_refund_to_invoice_qty/wizards/account_move_reversal.py
create mode 100644 sale_line_refund_to_invoice_qty/wizards/account_move_reversal_view.xml
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..111ab2088ba
--- /dev/null
+++ b/sale_line_refund_to_invoice_qty/README.rst
@@ -0,0 +1,87 @@
+===============================
+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/13.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-13-0/account-invoicing-13-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/13.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
+
+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..86851ba68a8
--- /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": "13.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/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..265cd10269c
--- /dev/null
+++ b/sale_line_refund_to_invoice_qty/i18n/sale_line_refund_to_invoice_qty.pot
@@ -0,0 +1,63 @@
+# 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 13.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.fields,help:sale_line_refund_to_invoice_qty.field_account_move_reversal__sale_qty_not_to_reinvoice
+msgid ""
+"If marked, the quantities refunded in the credit notes will not be "
+"considered as quantities to be reinvoiced in the related Sales Orders"
+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_not_to_reinvoice
+msgid ""
+"If marked, the quantity in this move line will not be considered as quantity"
+" to be reinvoiced in the related sales order line."
+msgstr ""
+
+#. module: sale_line_refund_to_invoice_qty
+#: model:ir.model,name:sale_line_refund_to_invoice_qty.model_account_move
+msgid "Journal Entries"
+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,field_description:sale_line_refund_to_invoice_qty.field_account_move_reversal__sale_qty_not_to_reinvoice
+msgid "Not reinvoice refunded quantity"
+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_not_to_reinvoice
+msgid "Sale qty not 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 ""
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..0c4adb2f01a
--- /dev/null
+++ b/sale_line_refund_to_invoice_qty/models/account.py
@@ -0,0 +1,28 @@
+# 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 AccountMove(models.Model):
+ _inherit = "account.move"
+
+ def _reverse_move_vals(self, default_values, cancel=True):
+ # Set the sale_qty_not_to_reinvoice based on the boolean from the
+ # reversal wizard
+ move_vals = super(AccountMove, self)._reverse_move_vals(
+ default_values, cancel=cancel
+ )
+ if self.env.context.get("sale_qty_not_to_reinvoice", False):
+ for vals in move_vals["line_ids"]:
+ vals[2].update({"sale_qty_not_to_reinvoice": True})
+ return move_vals
+
+
+class AccountMoveLine(models.Model):
+ _inherit = "account.move.line"
+
+ sale_qty_not_to_reinvoice = fields.Boolean(
+ string="Sale qty not to reinvoice",
+ help="If marked, the quantity in this move line will not be considered "
+ "as quantity to be reinvoiced in the related sales order line.",
+ )
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..227754208f9
--- /dev/null
+++ b/sale_line_refund_to_invoice_qty/models/sale.py
@@ -0,0 +1,57 @@
+# 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(
+ "qty_invoiced",
+ "qty_delivered",
+ "product_uom_qty",
+ "order_id.state",
+ "invoice_lines.move_id.state",
+ "invoice_lines.quantity",
+ "invoice_lines.sale_qty_not_to_reinvoice",
+ )
+ def _get_to_invoice_qty(self):
+ super()._get_to_invoice_qty()
+ for line in self:
+ qty_to_invoice = line.qty_to_invoice
+ for invoice_line in line.invoice_lines:
+ if (
+ invoice_line.move_id.state != "cancel"
+ and invoice_line.move_id.type == "out_refund"
+ and invoice_line.sale_qty_not_to_reinvoice
+ ):
+ qty_to_invoice -= invoice_line.product_uom_id._compute_quantity(
+ invoice_line.quantity, line.product_uom
+ )
+ line.qty_to_invoice = qty_to_invoice
+
+ @api.depends(
+ "product_uom_qty",
+ "invoice_lines.move_id.state",
+ "invoice_lines.quantity",
+ "invoice_lines.sale_qty_not_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.type == "out_refund"
+ and invoice_line.sale_qty_not_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..e4263e418aa
--- /dev/null
+++ b/sale_line_refund_to_invoice_qty/readme/CONTRIBUTORS.rst
@@ -0,0 +1 @@
+* Jordi Masvidal
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 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d
GIT binary patch
literal 9455
zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~!
zVpnB`o+K7|Al`Q_U;eD$B
zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA
z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__
zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_
zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I
z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U
z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)(
z;)z%wI5>D4a*5XwD)P--sPkoY(a~WBw;E~AW`Yue4kFa^LM3X`8x|}ZUeMnqr}>kH
zG%WWW>3ml$Yez?i%)2pbKPI7?5o?hydokgQyZsNEr{a|mLdt;X2TX(#B1j35xPnPW
z*bMSSOauW>o;*=kO8ojw91VX!qoOQb)zHJ!odWB}d+*K?#sY_jqPdg{Sm2HdYzdEx
zOGVPhVRTGPtv0o}RfVP;Nd(|CB)I;*t&QO8h
zFfekr30S!-LHmV_Su-W+rEwY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J?o+40*OLl^{=&oq$<#Q(yyrp
z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{}
zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N
Xviia!U7SGha1wx#SCgwmn*{w2TRX*I
literal 0
HcmV?d00001
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..ba2fa417d3b
--- /dev/null
+++ b/sale_line_refund_to_invoice_qty/static/description/index.html
@@ -0,0 +1,432 @@
+
+
+
+
+
+
+Sale Line Refund To Invoice Qty
+
+
+
+
+
Sale Line Refund To Invoice Qty
+
+
+
+
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
+
+
+
+
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.
+
+
+
+
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.
+
+
+
+
+
+
+
+
This module is maintained by the OCA.
+
+
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..0157d3feec0
--- /dev/null
+++ b/sale_line_refund_to_invoice_qty/tests/test_sale_line_refund_to_invoice_qty.py
@@ -0,0 +1,74 @@
+# 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 SavepointCase, tagged
+
+
+@tagged("post_install", "-at_install")
+class TestSaleLineRefundToInvoiceQty(SavepointCase):
+ @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]
+
+ def move_reversal_wiz(self, move):
+ wizard = (
+ self.env["account.move.reversal"]
+ .with_context(active_model="account.move", active_ids=[move.id])
+ .create({})
+ )
+ 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.
+ """
+ reversal_wizard = self.move_reversal_wiz(self.invoice)
+ reversal_wizard.write({"sale_qty_not_to_reinvoice": True})
+ 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_not_to_reinvoice)
+ 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.
+ """
+ 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.assertFalse(line.sale_qty_not_to_reinvoice)
+ 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..f69cab1d86d
--- /dev/null
+++ b/sale_line_refund_to_invoice_qty/views/account_move_views.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+ 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..45488c9d425
--- /dev/null
+++ b/sale_line_refund_to_invoice_qty/wizards/account_move_reversal.py
@@ -0,0 +1,19 @@
+# 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_not_to_reinvoice = fields.Boolean(
+ string="Not reinvoice refunded quantity",
+ help="If marked, the quantities refunded in the credit notes will not "
+ "be considered as quantities to be reinvoiced in the related Sales Orders",
+ )
+
+ def reverse_moves(self):
+ return super(
+ AccountMoveReversal,
+ self.with_context(sale_qty_not_to_reinvoice=self.sale_qty_not_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..064d38d9394
--- /dev/null
+++ b/sale_line_refund_to_invoice_qty/wizards/account_move_reversal_view.xml
@@ -0,0 +1,19 @@
+
+
+
+
+ account.move.reversal.form.inherit
+ account.move.reversal
+
+
+
+
+
+
+
+
+
+
From 7f8462676a0b8a0945b3d568b1b4360626a11c5e Mon Sep 17 00:00:00 2001
From: JordiMForgeFlow
Date: Tue, 3 Aug 2021 13:41:27 +0200
Subject: [PATCH 2/9] [13.0][IMP]sale_line_refund_to_invoice_qty: add refund
option explanation for usability and only display on credit notes
---
.../__manifest__.py | 2 +-
.../i18n/sale_line_refund_to_invoice_qty.pot | 7 +++++++
.../wizards/account_move_reversal_view.xml | 18 +++++++++++-------
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/sale_line_refund_to_invoice_qty/__manifest__.py b/sale_line_refund_to_invoice_qty/__manifest__.py
index 86851ba68a8..e8330fb56c2 100644
--- a/sale_line_refund_to_invoice_qty/__manifest__.py
+++ b/sale_line_refund_to_invoice_qty/__manifest__.py
@@ -4,7 +4,7 @@
"name": "Sale Line Refund To Invoice Qty",
"summary": """Allow deciding whether refunded quantity should be considered
as quantity to reinvoice""",
- "version": "13.0.1.0.0",
+ "version": "13.0.1.0.1",
"category": "Sales",
"website": "https://github.com/OCA/account-invoicing",
"author": "ForgeFlow, Odoo Community Association (OCA)",
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
index 265cd10269c..63a42a70e54 100644
--- 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
@@ -32,6 +32,13 @@ msgid ""
" to be reinvoiced in the related sales order line."
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 ""
+"If the credit note is created to reverse a wrong invoice, leave the checkbox"
+" empty."
+msgstr ""
+
#. module: sale_line_refund_to_invoice_qty
#: model:ir.model,name:sale_line_refund_to_invoice_qty.model_account_move
msgid "Journal Entries"
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
index 064d38d9394..4f745a87fdb 100644
--- 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
@@ -6,13 +6,17 @@
account.move.reversal
-
-
-
-
+
+
+
+
+ If the credit note is created to reverse a wrong invoice, leave the checkbox empty.
+
+
+
From 3112d035893d038f64ce7efc22959ae1994462fa Mon Sep 17 00:00:00 2001
From: AaronHForgeFlow
Date: Fri, 27 Aug 2021 08:58:47 +0200
Subject: [PATCH 3/9] [IMP]sale_line_refund_to_invoice_qty: do not use negative
booleans
---
.../__manifest__.py | 2 +-
.../i18n/sale_line_refund_to_invoice_qty.pot | 44 +++++++++----------
.../migrations/13.0.1.1.1/post-migration.py | 31 +++++++++++++
.../migrations/13.0.1.1.1/pre-migration.py | 12 +++++
.../models/account.py | 13 +++---
.../models/sale.py | 8 ++--
.../test_sale_line_refund_to_invoice_qty.py | 6 +--
.../views/account_move_views.xml | 2 +-
.../wizards/account_move_reversal.py | 11 ++---
.../wizards/account_move_reversal_view.xml | 4 +-
10 files changed, 87 insertions(+), 46 deletions(-)
create mode 100644 sale_line_refund_to_invoice_qty/migrations/13.0.1.1.1/post-migration.py
create mode 100644 sale_line_refund_to_invoice_qty/migrations/13.0.1.1.1/pre-migration.py
diff --git a/sale_line_refund_to_invoice_qty/__manifest__.py b/sale_line_refund_to_invoice_qty/__manifest__.py
index e8330fb56c2..212733f910b 100644
--- a/sale_line_refund_to_invoice_qty/__manifest__.py
+++ b/sale_line_refund_to_invoice_qty/__manifest__.py
@@ -4,7 +4,7 @@
"name": "Sale Line Refund To Invoice Qty",
"summary": """Allow deciding whether refunded quantity should be considered
as quantity to reinvoice""",
- "version": "13.0.1.0.1",
+ "version": "13.0.1.2.0",
"category": "Sales",
"website": "https://github.com/OCA/account-invoicing",
"author": "ForgeFlow, Odoo Community Association (OCA)",
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
index 63a42a70e54..2e747ba72a4 100644
--- 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
@@ -19,39 +19,32 @@ msgid "Account Move Reversal"
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_not_to_reinvoice
-msgid ""
-"If marked, the quantities refunded in the credit notes will not be "
-"considered as quantities to be reinvoiced in the related Sales Orders"
+#: model:ir.model,name:sale_line_refund_to_invoice_qty.model_account_move
+msgid "Journal Entries"
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_not_to_reinvoice
-msgid ""
-"If marked, the quantity in this move line will not be considered as quantity"
-" to be reinvoiced in the related sales order line."
+#: 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_terms:ir.ui.view,arch_db:sale_line_refund_to_invoice_qty.view_account_move_reversal
-msgid ""
-"If the credit note is created to reverse a wrong invoice, leave the checkbox"
-" empty."
+#: 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,name:sale_line_refund_to_invoice_qty.model_account_move
-msgid "Journal Entries"
-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"
+#: 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:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_reversal__sale_qty_not_to_reinvoice
-msgid "Not reinvoice refunded quantity"
+#: 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
@@ -60,11 +53,16 @@ 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_not_to_reinvoice
-msgid "Sale qty not to reinvoice"
+#: 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/migrations/13.0.1.1.1/post-migration.py b/sale_line_refund_to_invoice_qty/migrations/13.0.1.1.1/post-migration.py
new file mode 100644
index 00000000000..90ca1f13dff
--- /dev/null
+++ b/sale_line_refund_to_invoice_qty/migrations/13.0.1.1.1/post-migration.py
@@ -0,0 +1,31 @@
+# Copyright 2021 ForgeFlow
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+from openupgradelib import openupgrade
+
+
+def sale_qty_to_reinvoice_swapping(env):
+ openupgrade.logged_query(
+ env.cr,
+ """
+ UPDATE account_move_line aml
+ SET sale_qty_to_reinvoice = true
+ WHERE aml.{} = false
+ """.format(
+ openupgrade.get_legacy_name("sale_qty_not_to_reinvoice")
+ ),
+ )
+ openupgrade.logged_query(
+ env.cr,
+ """
+ UPDATE account_move_line aml
+ SET sale_qty_to_reinvoice = false
+ WHERE aml.{} = true
+ """.format(
+ openupgrade.get_legacy_name("sale_qty_not_to_reinvoice")
+ ),
+ )
+
+
+@openupgrade.migrate()
+def migrate(env, version):
+ sale_qty_to_reinvoice_swapping(env)
diff --git a/sale_line_refund_to_invoice_qty/migrations/13.0.1.1.1/pre-migration.py b/sale_line_refund_to_invoice_qty/migrations/13.0.1.1.1/pre-migration.py
new file mode 100644
index 00000000000..50ee2e2ead2
--- /dev/null
+++ b/sale_line_refund_to_invoice_qty/migrations/13.0.1.1.1/pre-migration.py
@@ -0,0 +1,12 @@
+# Copyright 2021 ForgeFlow
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+from openupgradelib import openupgrade
+
+_column_copies = {
+ "account_move_line": [("sale_qty_not_to_reinvoice", None, None)],
+}
+
+
+@openupgrade.migrate()
+def migrate(env, version):
+ openupgrade.copy_columns(env.cr, _column_copies)
diff --git a/sale_line_refund_to_invoice_qty/models/account.py b/sale_line_refund_to_invoice_qty/models/account.py
index 0c4adb2f01a..e0b2d336891 100644
--- a/sale_line_refund_to_invoice_qty/models/account.py
+++ b/sale_line_refund_to_invoice_qty/models/account.py
@@ -7,22 +7,21 @@ class AccountMove(models.Model):
_inherit = "account.move"
def _reverse_move_vals(self, default_values, cancel=True):
- # Set the sale_qty_not_to_reinvoice based on the boolean from the
+ # Set the sale_qty_to_reinvoice based on the boolean from the
# reversal wizard
move_vals = super(AccountMove, self)._reverse_move_vals(
default_values, cancel=cancel
)
- if self.env.context.get("sale_qty_not_to_reinvoice", False):
+ if self.env.context.get("sale_qty_to_reinvoice", False):
for vals in move_vals["line_ids"]:
- vals[2].update({"sale_qty_not_to_reinvoice": True})
+ vals[2].update({"sale_qty_to_reinvoice": True})
return move_vals
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
- sale_qty_not_to_reinvoice = fields.Boolean(
- string="Sale qty not to reinvoice",
- help="If marked, the quantity in this move line will not be considered "
- "as quantity to be reinvoiced in the related sales order line.",
+ sale_qty_to_reinvoice = fields.Boolean(
+ string="Sale qty to reinvoice",
+ help="Leave it marked if you will reinvoice the same sale order line",
)
diff --git a/sale_line_refund_to_invoice_qty/models/sale.py b/sale_line_refund_to_invoice_qty/models/sale.py
index 227754208f9..ca1e72f936d 100644
--- a/sale_line_refund_to_invoice_qty/models/sale.py
+++ b/sale_line_refund_to_invoice_qty/models/sale.py
@@ -19,7 +19,7 @@ class SaleOrderLine(models.Model):
"order_id.state",
"invoice_lines.move_id.state",
"invoice_lines.quantity",
- "invoice_lines.sale_qty_not_to_reinvoice",
+ "invoice_lines.sale_qty_to_reinvoice",
)
def _get_to_invoice_qty(self):
super()._get_to_invoice_qty()
@@ -29,7 +29,7 @@ def _get_to_invoice_qty(self):
if (
invoice_line.move_id.state != "cancel"
and invoice_line.move_id.type == "out_refund"
- and invoice_line.sale_qty_not_to_reinvoice
+ and not invoice_line.sale_qty_to_reinvoice
):
qty_to_invoice -= invoice_line.product_uom_id._compute_quantity(
invoice_line.quantity, line.product_uom
@@ -40,7 +40,7 @@ def _get_to_invoice_qty(self):
"product_uom_qty",
"invoice_lines.move_id.state",
"invoice_lines.quantity",
- "invoice_lines.sale_qty_not_to_reinvoice",
+ "invoice_lines.sale_qty_to_reinvoice",
)
def _compute_qty_refunded_not_invoiceable(self):
for line in self:
@@ -49,7 +49,7 @@ def _compute_qty_refunded_not_invoiceable(self):
if (
invoice_line.move_id.state != "cancel"
and invoice_line.move_id.type == "out_refund"
- and invoice_line.sale_qty_not_to_reinvoice
+ 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
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
index 0157d3feec0..bd93f9c7d6e 100644
--- 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
@@ -50,12 +50,12 @@ def test_refund_qty_not_to_reinvoice(self):
reinvoice in the sales order line, when the boolean is checked.
"""
reversal_wizard = self.move_reversal_wiz(self.invoice)
- reversal_wizard.write({"sale_qty_not_to_reinvoice": True})
+ 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.assertTrue(line.sale_qty_not_to_reinvoice)
+ self.assertFalse(line.sale_qty_to_reinvoice)
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)
@@ -69,6 +69,6 @@ def test_refund_qty_to_reinvoice(self):
reversal_wizard.reverse_moves()["res_id"]
)
for line in credit_note.line_ids:
- self.assertFalse(line.sale_qty_not_to_reinvoice)
+ self.assertTrue(line.sale_qty_to_reinvoice)
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
index f69cab1d86d..3c2d5278463 100644
--- a/sale_line_refund_to_invoice_qty/views/account_move_views.xml
+++ b/sale_line_refund_to_invoice_qty/views/account_move_views.xml
@@ -10,7 +10,7 @@ License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -->
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
index 45488c9d425..34ca3b73101 100644
--- a/sale_line_refund_to_invoice_qty/wizards/account_move_reversal.py
+++ b/sale_line_refund_to_invoice_qty/wizards/account_move_reversal.py
@@ -6,14 +6,15 @@
class AccountMoveReversal(models.TransientModel):
_inherit = "account.move.reversal"
- sale_qty_not_to_reinvoice = fields.Boolean(
- string="Not reinvoice refunded quantity",
- help="If marked, the quantities refunded in the credit notes will not "
- "be considered as quantities to be reinvoiced in the related Sales Orders",
+ 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):
return super(
AccountMoveReversal,
- self.with_context(sale_qty_not_to_reinvoice=self.sale_qty_not_to_reinvoice),
+ self.with_context(sale_qty_to_reinvoice=self.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
index 4f745a87fdb..eaac139ce2a 100644
--- 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
@@ -11,9 +11,9 @@
name="sale_line_refund_qty"
attrs="{'invisible': [('move_type', '!=', 'out_invoice')]}"
>
-
+
- If the credit note is created to reverse a wrong invoice, leave the checkbox empty.
+ Leave it marked when other customer invoices are expected for the quantities in the credit note.
From 6e314754ece6dff67b867668673b34c17f5aa075 Mon Sep 17 00:00:00 2001
From: GuillemCForgeFlow
Date: Fri, 26 Nov 2021 14:57:00 +0100
Subject: [PATCH 4/9] [14.0][MIG]sale_line_refund_to_invoice_qty: Migration to
14.0
---
sale_line_refund_to_invoice_qty/README.rst | 10 +++---
.../__manifest__.py | 2 +-
.../i18n/sale_line_refund_to_invoice_qty.pot | 28 +++++++++++++++--
.../migrations/13.0.1.1.1/post-migration.py | 31 -------------------
.../migrations/13.0.1.1.1/pre-migration.py | 12 -------
.../models/sale.py | 4 +--
.../static/description/index.html | 6 ++--
.../test_sale_line_refund_to_invoice_qty.py | 1 +
.../views/account_move_views.xml | 2 +-
9 files changed, 39 insertions(+), 57 deletions(-)
delete mode 100644 sale_line_refund_to_invoice_qty/migrations/13.0.1.1.1/post-migration.py
delete mode 100644 sale_line_refund_to_invoice_qty/migrations/13.0.1.1.1/pre-migration.py
diff --git a/sale_line_refund_to_invoice_qty/README.rst b/sale_line_refund_to_invoice_qty/README.rst
index 111ab2088ba..dc1a1804682 100644
--- a/sale_line_refund_to_invoice_qty/README.rst
+++ b/sale_line_refund_to_invoice_qty/README.rst
@@ -14,13 +14,13 @@ Sale Line Refund To Invoice Qty
: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/13.0/sale_line_refund_to_invoice_qty
+ :target: https://github.com/OCA/account-invoicing/tree/14.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-13-0/account-invoicing-13-0-sale_line_refund_to_invoice_qty
+ :target: https://translation.odoo-community.org/projects/account-invoicing-14-0/account-invoicing-14-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/13.0
+ :target: https://runbot.odoo-community.org/runbot/95/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -52,7 +52,7 @@ 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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -82,6 +82,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/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/__manifest__.py b/sale_line_refund_to_invoice_qty/__manifest__.py
index 212733f910b..c9fa9c6f50a 100644
--- a/sale_line_refund_to_invoice_qty/__manifest__.py
+++ b/sale_line_refund_to_invoice_qty/__manifest__.py
@@ -4,7 +4,7 @@
"name": "Sale Line Refund To Invoice Qty",
"summary": """Allow deciding whether refunded quantity should be considered
as quantity to reinvoice""",
- "version": "13.0.1.2.0",
+ "version": "14.0.1.0.0",
"category": "Sales",
"website": "https://github.com/OCA/account-invoicing",
"author": "ForgeFlow, Odoo Community Association (OCA)",
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
index 2e747ba72a4..3285499c44f 100644
--- 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
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 13.0\n"
+"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -18,9 +18,25 @@ msgstr ""
msgid "Account Move Reversal"
msgstr ""
+#. module: sale_line_refund_to_invoice_qty
+#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move__display_name
+#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_line__display_name
+#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_reversal__display_name
+#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_sale_order_line__display_name
+msgid "Display Name"
+msgstr ""
+
+#. module: sale_line_refund_to_invoice_qty
+#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move__id
+#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_line__id
+#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_reversal__id
+#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_sale_order_line__id
+msgid "ID"
+msgstr ""
+
#. module: sale_line_refund_to_invoice_qty
#: model:ir.model,name:sale_line_refund_to_invoice_qty.model_account_move
-msgid "Journal Entries"
+msgid "Journal Entry"
msgstr ""
#. module: sale_line_refund_to_invoice_qty
@@ -28,6 +44,14 @@ msgstr ""
msgid "Journal Item"
msgstr ""
+#. module: sale_line_refund_to_invoice_qty
+#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move____last_update
+#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_line____last_update
+#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_reversal____last_update
+#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_sale_order_line____last_update
+msgid "Last Modified on"
+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"
diff --git a/sale_line_refund_to_invoice_qty/migrations/13.0.1.1.1/post-migration.py b/sale_line_refund_to_invoice_qty/migrations/13.0.1.1.1/post-migration.py
deleted file mode 100644
index 90ca1f13dff..00000000000
--- a/sale_line_refund_to_invoice_qty/migrations/13.0.1.1.1/post-migration.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2021 ForgeFlow
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from openupgradelib import openupgrade
-
-
-def sale_qty_to_reinvoice_swapping(env):
- openupgrade.logged_query(
- env.cr,
- """
- UPDATE account_move_line aml
- SET sale_qty_to_reinvoice = true
- WHERE aml.{} = false
- """.format(
- openupgrade.get_legacy_name("sale_qty_not_to_reinvoice")
- ),
- )
- openupgrade.logged_query(
- env.cr,
- """
- UPDATE account_move_line aml
- SET sale_qty_to_reinvoice = false
- WHERE aml.{} = true
- """.format(
- openupgrade.get_legacy_name("sale_qty_not_to_reinvoice")
- ),
- )
-
-
-@openupgrade.migrate()
-def migrate(env, version):
- sale_qty_to_reinvoice_swapping(env)
diff --git a/sale_line_refund_to_invoice_qty/migrations/13.0.1.1.1/pre-migration.py b/sale_line_refund_to_invoice_qty/migrations/13.0.1.1.1/pre-migration.py
deleted file mode 100644
index 50ee2e2ead2..00000000000
--- a/sale_line_refund_to_invoice_qty/migrations/13.0.1.1.1/pre-migration.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2021 ForgeFlow
-# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
-from openupgradelib import openupgrade
-
-_column_copies = {
- "account_move_line": [("sale_qty_not_to_reinvoice", None, None)],
-}
-
-
-@openupgrade.migrate()
-def migrate(env, version):
- openupgrade.copy_columns(env.cr, _column_copies)
diff --git a/sale_line_refund_to_invoice_qty/models/sale.py b/sale_line_refund_to_invoice_qty/models/sale.py
index ca1e72f936d..184d257ce3c 100644
--- a/sale_line_refund_to_invoice_qty/models/sale.py
+++ b/sale_line_refund_to_invoice_qty/models/sale.py
@@ -28,7 +28,7 @@ def _get_to_invoice_qty(self):
for invoice_line in line.invoice_lines:
if (
invoice_line.move_id.state != "cancel"
- and invoice_line.move_id.type == "out_refund"
+ and invoice_line.move_id.move_type == "out_refund"
and not invoice_line.sale_qty_to_reinvoice
):
qty_to_invoice -= invoice_line.product_uom_id._compute_quantity(
@@ -48,7 +48,7 @@ def _compute_qty_refunded_not_invoiceable(self):
for invoice_line in line.invoice_lines:
if (
invoice_line.move_id.state != "cancel"
- and invoice_line.move_id.type == "out_refund"
+ 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(
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 ba2fa417d3b..f32469630e2 100644
--- a/sale_line_refund_to_invoice_qty/static/description/index.html
+++ b/sale_line_refund_to_invoice_qty/static/description/index.html
@@ -367,7 +367,7 @@ Sale Line Refund To Invoice Qty
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
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
@@ -399,7 +399,7 @@
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.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -423,7 +423,7 @@
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/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/test_sale_line_refund_to_invoice_qty.py b/sale_line_refund_to_invoice_qty/tests/test_sale_line_refund_to_invoice_qty.py
index bd93f9c7d6e..3fbf88398cb 100644
--- 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
@@ -35,6 +35,7 @@ def setUpClass(cls):
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 = (
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
index 3c2d5278463..8b764d6b84b 100644
--- a/sale_line_refund_to_invoice_qty/views/account_move_views.xml
+++ b/sale_line_refund_to_invoice_qty/views/account_move_views.xml
@@ -11,7 +11,7 @@ License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -->
From f99600d22096385b6f3c2a8aeba6612bfa53bd71 Mon Sep 17 00:00:00 2001
From: Jasmin Solanki
Date: Tue, 28 Jun 2022 11:59:12 +0530
Subject: [PATCH 5/9] [MIG] sale_line_refund_to_invoice_qty: Migration to 15.0
---
sale_line_refund_to_invoice_qty/README.rst | 10 +++----
.../__manifest__.py | 2 +-
.../i18n/sale_line_refund_to_invoice_qty.pot | 28 ++-----------------
.../models/account.py | 1 -
.../models/sale.py | 3 +-
.../static/description/index.html | 6 ++--
.../test_sale_line_refund_to_invoice_qty.py | 6 ++--
.../views/account_move_views.xml | 10 +++----
.../wizards/account_move_reversal_view.xml | 8 ++----
9 files changed, 23 insertions(+), 51 deletions(-)
diff --git a/sale_line_refund_to_invoice_qty/README.rst b/sale_line_refund_to_invoice_qty/README.rst
index dc1a1804682..07b2ea51e73 100644
--- a/sale_line_refund_to_invoice_qty/README.rst
+++ b/sale_line_refund_to_invoice_qty/README.rst
@@ -14,13 +14,13 @@ Sale Line Refund To Invoice Qty
: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/14.0/sale_line_refund_to_invoice_qty
+ :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-14-0/account-invoicing-14-0-sale_line_refund_to_invoice_qty
+ :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/14.0
+ :target: https://runbot.odoo-community.org/runbot/95/15.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -52,7 +52,7 @@ 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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -82,6 +82,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/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/__manifest__.py b/sale_line_refund_to_invoice_qty/__manifest__.py
index c9fa9c6f50a..7cb3308b798 100644
--- a/sale_line_refund_to_invoice_qty/__manifest__.py
+++ b/sale_line_refund_to_invoice_qty/__manifest__.py
@@ -4,7 +4,7 @@
"name": "Sale Line Refund To Invoice Qty",
"summary": """Allow deciding whether refunded quantity should be considered
as quantity to reinvoice""",
- "version": "14.0.1.0.0",
+ "version": "15.0.1.0.0",
"category": "Sales",
"website": "https://github.com/OCA/account-invoicing",
"author": "ForgeFlow, Odoo Community Association (OCA)",
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
index 3285499c44f..844d879d8cd 100644
--- 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
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 14.0\n"
+"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -18,22 +18,6 @@ msgstr ""
msgid "Account Move Reversal"
msgstr ""
-#. module: sale_line_refund_to_invoice_qty
-#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move__display_name
-#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_line__display_name
-#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_reversal__display_name
-#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_sale_order_line__display_name
-msgid "Display Name"
-msgstr ""
-
-#. module: sale_line_refund_to_invoice_qty
-#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move__id
-#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_line__id
-#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_reversal__id
-#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_sale_order_line__id
-msgid "ID"
-msgstr ""
-
#. module: sale_line_refund_to_invoice_qty
#: model:ir.model,name:sale_line_refund_to_invoice_qty.model_account_move
msgid "Journal Entry"
@@ -44,14 +28,6 @@ msgstr ""
msgid "Journal Item"
msgstr ""
-#. module: sale_line_refund_to_invoice_qty
-#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move____last_update
-#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_line____last_update
-#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_account_move_reversal____last_update
-#: model:ir.model.fields,field_description:sale_line_refund_to_invoice_qty.field_sale_order_line____last_update
-msgid "Last Modified on"
-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"
@@ -78,7 +54,7 @@ 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"
+msgid "Sale Qty To Reinvoice"
msgstr ""
#. module: sale_line_refund_to_invoice_qty
diff --git a/sale_line_refund_to_invoice_qty/models/account.py b/sale_line_refund_to_invoice_qty/models/account.py
index e0b2d336891..2baf5b3d7e7 100644
--- a/sale_line_refund_to_invoice_qty/models/account.py
+++ b/sale_line_refund_to_invoice_qty/models/account.py
@@ -22,6 +22,5 @@ class AccountMoveLine(models.Model):
_inherit = "account.move.line"
sale_qty_to_reinvoice = fields.Boolean(
- string="Sale qty to reinvoice",
help="Leave it marked if you will reinvoice the same sale order line",
)
diff --git a/sale_line_refund_to_invoice_qty/models/sale.py b/sale_line_refund_to_invoice_qty/models/sale.py
index 184d257ce3c..8929042b7fb 100644
--- a/sale_line_refund_to_invoice_qty/models/sale.py
+++ b/sale_line_refund_to_invoice_qty/models/sale.py
@@ -22,7 +22,7 @@ class SaleOrderLine(models.Model):
"invoice_lines.sale_qty_to_reinvoice",
)
def _get_to_invoice_qty(self):
- super()._get_to_invoice_qty()
+ res = super()._get_to_invoice_qty()
for line in self:
qty_to_invoice = line.qty_to_invoice
for invoice_line in line.invoice_lines:
@@ -35,6 +35,7 @@ def _get_to_invoice_qty(self):
invoice_line.quantity, line.product_uom
)
line.qty_to_invoice = qty_to_invoice
+ return res
@api.depends(
"product_uom_qty",
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 f32469630e2..184453223eb 100644
--- a/sale_line_refund_to_invoice_qty/static/description/index.html
+++ b/sale_line_refund_to_invoice_qty/static/description/index.html
@@ -367,7 +367,7 @@ Sale Line Refund To Invoice Qty
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
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
@@ -399,7 +399,7 @@
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.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -423,7 +423,7 @@
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/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/test_sale_line_refund_to_invoice_qty.py b/sale_line_refund_to_invoice_qty/tests/test_sale_line_refund_to_invoice_qty.py
index 3fbf88398cb..191d9bbf39c 100644
--- 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
@@ -1,10 +1,10 @@
# 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 SavepointCase, tagged
+from odoo.tests.common import TransactionCase, tagged
@tagged("post_install", "-at_install")
-class TestSaleLineRefundToInvoiceQty(SavepointCase):
+class TestSaleLineRefundToInvoiceQty(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
@@ -41,7 +41,7 @@ def move_reversal_wiz(self, move):
wizard = (
self.env["account.move.reversal"]
.with_context(active_model="account.move", active_ids=[move.id])
- .create({})
+ .create({"journal_id": move.journal_id.id})
)
return wizard
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
index 8b764d6b84b..9a730d8e86f 100644
--- a/sale_line_refund_to_invoice_qty/views/account_move_views.xml
+++ b/sale_line_refund_to_invoice_qty/views/account_move_views.xml
@@ -2,7 +2,6 @@
-
account.move.form.inherit
account.move
@@ -10,12 +9,11 @@ License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -->
+ name="sale_qty_to_reinvoice"
+ attrs="{'column_invisible': [('parent.move_type', '!=', 'out_refund')]}"
+ optional="show"
+ />
-
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
index eaac139ce2a..eca3f47d296 100644
--- 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
@@ -1,6 +1,5 @@
-
account.move.reversal.form.inherit
account.move.reversal
@@ -8,9 +7,9 @@
+ name="sale_line_refund_qty"
+ attrs="{'invisible': [('move_type', '!=', 'out_invoice')]}"
+ >
Leave it marked when other customer invoices are expected for the quantities in the credit note.
@@ -19,5 +18,4 @@
-
From 43f651846fc745255cfe94b5f05d7ee711865ba8 Mon Sep 17 00:00:00 2001
From: Lois Rilo
Date: Tue, 27 Dec 2022 11:34:27 +0100
Subject: [PATCH 6/9] [FIX] sale_line_refund_to_invoice_qty: do not change
invoiced qty
when you mark a refund to not be reinvoiced, the invoice qty
should not be reduced, because it is already invoiced and you
won't invoice it again.
---
sale_line_refund_to_invoice_qty/README.rst | 1 +
sale_line_refund_to_invoice_qty/__manifest__.py | 2 +-
sale_line_refund_to_invoice_qty/models/sale.py | 17 ++++++++---------
.../readme/CONTRIBUTORS.rst | 1 +
.../static/description/index.html | 1 +
.../test_sale_line_refund_to_invoice_qty.py | 4 ++++
6 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/sale_line_refund_to_invoice_qty/README.rst b/sale_line_refund_to_invoice_qty/README.rst
index 07b2ea51e73..6b832cca4db 100644
--- a/sale_line_refund_to_invoice_qty/README.rst
+++ b/sale_line_refund_to_invoice_qty/README.rst
@@ -68,6 +68,7 @@ Contributors
~~~~~~~~~~~~
* Jordi Masvidal
+* Lois Rilo
Maintainers
~~~~~~~~~~~
diff --git a/sale_line_refund_to_invoice_qty/__manifest__.py b/sale_line_refund_to_invoice_qty/__manifest__.py
index 7cb3308b798..f33aa669cc3 100644
--- a/sale_line_refund_to_invoice_qty/__manifest__.py
+++ b/sale_line_refund_to_invoice_qty/__manifest__.py
@@ -4,7 +4,7 @@
"name": "Sale Line Refund To Invoice Qty",
"summary": """Allow deciding whether refunded quantity should be considered
as quantity to reinvoice""",
- "version": "15.0.1.0.0",
+ "version": "15.0.1.0.1",
"category": "Sales",
"website": "https://github.com/OCA/account-invoicing",
"author": "ForgeFlow, Odoo Community Association (OCA)",
diff --git a/sale_line_refund_to_invoice_qty/models/sale.py b/sale_line_refund_to_invoice_qty/models/sale.py
index 8929042b7fb..f43b2d71366 100644
--- a/sale_line_refund_to_invoice_qty/models/sale.py
+++ b/sale_line_refund_to_invoice_qty/models/sale.py
@@ -13,28 +13,27 @@ class SaleOrderLine(models.Model):
)
@api.depends(
- "qty_invoiced",
- "qty_delivered",
- "product_uom_qty",
- "order_id.state",
"invoice_lines.move_id.state",
"invoice_lines.quantity",
+ "untaxed_amount_to_invoice",
"invoice_lines.sale_qty_to_reinvoice",
)
- def _get_to_invoice_qty(self):
- res = super()._get_to_invoice_qty()
+ 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_to_invoice = line.qty_to_invoice
+ 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_to_invoice -= invoice_line.product_uom_id._compute_quantity(
+ qty_invoiced += invoice_line.product_uom_id._compute_quantity(
invoice_line.quantity, line.product_uom
)
- line.qty_to_invoice = qty_to_invoice
+ line.qty_invoiced = qty_invoiced
return res
@api.depends(
diff --git a/sale_line_refund_to_invoice_qty/readme/CONTRIBUTORS.rst b/sale_line_refund_to_invoice_qty/readme/CONTRIBUTORS.rst
index e4263e418aa..90dd6c9906b 100644
--- a/sale_line_refund_to_invoice_qty/readme/CONTRIBUTORS.rst
+++ b/sale_line_refund_to_invoice_qty/readme/CONTRIBUTORS.rst
@@ -1 +1,2 @@
* Jordi Masvidal
+* Lois Rilo
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 184453223eb..95fb65c47f8 100644
--- a/sale_line_refund_to_invoice_qty/static/description/index.html
+++ b/sale_line_refund_to_invoice_qty/static/description/index.html
@@ -414,6 +414,7 @@
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
index 191d9bbf39c..aa082853bc5 100644
--- 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
@@ -50,6 +50,7 @@ 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(
@@ -57,6 +58,7 @@ def test_refund_qty_not_to_reinvoice(self):
)
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)
@@ -65,11 +67,13 @@ 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)
From 33cea613bac0c22b8d52bac222cd08e4e6b05553 Mon Sep 17 00:00:00 2001
From: Christopher Ormaza
Date: Thu, 16 Feb 2023 07:57:02 -0500
Subject: [PATCH 7/9] [15.0][FIX] sale_line_refund_to_invoice_qty, fix default
value on aml
---
.../__manifest__.py | 2 +-
.../15.0.2.0.1/post-fix-old-field-value.py | 60 +++++++++++++++++++
.../models/account.py | 8 ++-
3 files changed, 66 insertions(+), 4 deletions(-)
create mode 100644 sale_line_refund_to_invoice_qty/migrations/15.0.2.0.1/post-fix-old-field-value.py
diff --git a/sale_line_refund_to_invoice_qty/__manifest__.py b/sale_line_refund_to_invoice_qty/__manifest__.py
index f33aa669cc3..15a5cceb2cc 100644
--- a/sale_line_refund_to_invoice_qty/__manifest__.py
+++ b/sale_line_refund_to_invoice_qty/__manifest__.py
@@ -4,7 +4,7 @@
"name": "Sale Line Refund To Invoice Qty",
"summary": """Allow deciding whether refunded quantity should be considered
as quantity to reinvoice""",
- "version": "15.0.1.0.1",
+ "version": "15.0.2.0.1",
"category": "Sales",
"website": "https://github.com/OCA/account-invoicing",
"author": "ForgeFlow, Odoo Community Association (OCA)",
diff --git a/sale_line_refund_to_invoice_qty/migrations/15.0.2.0.1/post-fix-old-field-value.py b/sale_line_refund_to_invoice_qty/migrations/15.0.2.0.1/post-fix-old-field-value.py
new file mode 100644
index 00000000000..091f7210db9
--- /dev/null
+++ b/sale_line_refund_to_invoice_qty/migrations/15.0.2.0.1/post-fix-old-field-value.py
@@ -0,0 +1,60 @@
+import logging
+
+from odoo import SUPERUSER_ID, api
+
+_logger = logging.getLogger(__name__)
+
+
+def migrate(cr, version):
+ env = api.Environment(cr, SUPERUSER_ID, {})
+ sol_model = env["sale.order.line"]
+ field_definition = env["ir.model.fields"].search(
+ [("name", "=", "sale_qty_to_reinvoice"), ("model", "=", "account.move.line")],
+ limit=1,
+ )
+ if field_definition:
+ env.cr.execute(
+ """
+ update account_move_line set sale_qty_to_reinvoice = True
+ where create_date <= %s and
+ (sale_qty_to_reinvoice = False or sale_qty_to_reinvoice is null)
+ """,
+ (field_definition.create_date or field_definition.write_date,),
+ )
+ env.cr.commit()
+ query = """
+ with invoice_lines as (
+ select rel.order_line_id, sum(coalesce(aml.quantity, 0)) as quantity
+ from account_move_line as aml
+ inner join account_move as am on am.id = aml.move_id
+ inner join sale_order_line_invoice_rel as rel on rel.invoice_line_id = aml.id
+ where am.state = 'posted' and am.move_type = 'out_invoice'
+ group by rel.order_line_id
+ ), credit_lines as (
+ select rel.order_line_id, sum(coalesce(aml.quantity, 0)) as quantity
+ from account_move_line as aml
+ inner join account_move as am on am.id = aml.move_id
+ inner join sale_order_line_invoice_rel as rel on rel.invoice_line_id = aml.id
+ where am.state = 'posted' and am.move_type = 'out_refund'
+ and aml.sale_qty_to_reinvoice = true
+ group by rel.order_line_id
+ )
+ select
+ sol.id
+ from sale_order_line as sol
+ inner join sale_order as so on so.id = sol.order_id and so.state in ('sale', 'done')
+ left join invoice_lines as il on sol.id = il.order_line_id
+ left join credit_lines as cl on sol.id = cl.order_line_id
+ where (coalesce(il.quantity, 0) - coalesce(cl.quantity, 0)) != sol.qty_invoiced
+
+ """
+ env.cr.execute(query)
+ lines_with_problems = [data[0] for data in env.cr.fetchall()]
+ if lines_with_problems:
+ _logger.debug("total lines to reprocess: %s", str(len(lines_with_problems)))
+ sol_model.search(
+ [
+ ("id", "in", lines_with_problems),
+ ("product_id.type", "!=", "service"),
+ ]
+ )._compute_qty_invoiced()
diff --git a/sale_line_refund_to_invoice_qty/models/account.py b/sale_line_refund_to_invoice_qty/models/account.py
index 2baf5b3d7e7..2509a054145 100644
--- a/sale_line_refund_to_invoice_qty/models/account.py
+++ b/sale_line_refund_to_invoice_qty/models/account.py
@@ -12,9 +12,9 @@ def _reverse_move_vals(self, default_values, cancel=True):
move_vals = super(AccountMove, self)._reverse_move_vals(
default_values, cancel=cancel
)
- if self.env.context.get("sale_qty_to_reinvoice", False):
- for vals in move_vals["line_ids"]:
- vals[2].update({"sale_qty_to_reinvoice": True})
+ sale_qty_to_reinvoice = self.env.context.get("sale_qty_to_reinvoice", False)
+ for vals in move_vals["line_ids"]:
+ vals[2].update({"sale_qty_to_reinvoice": sale_qty_to_reinvoice})
return move_vals
@@ -22,5 +22,7 @@ class AccountMoveLine(models.Model):
_inherit = "account.move.line"
sale_qty_to_reinvoice = fields.Boolean(
+ string="Sale qty to reinvoice",
+ default=True,
help="Leave it marked if you will reinvoice the same sale order line",
)
From 632c52cbf54bf5e72cadd23ea79b228340a2ef95 Mon Sep 17 00:00:00 2001
From: Javier Iniesta
Date: Thu, 6 Jul 2023 12:58:27 +0200
Subject: [PATCH 8/9] [IMP] sale_line_refund_to_invoice_qty: pre-commit stuff
---
.../odoo/addons/sale_line_refund_to_invoice_qty | 1 +
setup/sale_line_refund_to_invoice_qty/setup.py | 6 ++++++
2 files changed, 7 insertions(+)
create mode 120000 setup/sale_line_refund_to_invoice_qty/odoo/addons/sale_line_refund_to_invoice_qty
create mode 100644 setup/sale_line_refund_to_invoice_qty/setup.py
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,
+)
From 4502e3c9674fa340f15c49583f26a9b0160d6d5c Mon Sep 17 00:00:00 2001
From: Javier Iniesta
Date: Thu, 6 Jul 2023 13:11:40 +0200
Subject: [PATCH 9/9] [MIG] sale_line_refund_to_invoice_qty: Migration to 16.0
---
.../__manifest__.py | 2 +-
sale_line_refund_to_invoice_qty/i18n/es.po | 70 +++++++++++++++++++
.../15.0.2.0.1/post-fix-old-field-value.py | 60 ----------------
.../models/account.py | 16 ++---
.../models/sale.py | 3 +-
.../wizards/account_move_reversal.py | 5 +-
.../wizards/account_move_reversal_view.xml | 2 +-
7 files changed, 85 insertions(+), 73 deletions(-)
create mode 100644 sale_line_refund_to_invoice_qty/i18n/es.po
delete mode 100644 sale_line_refund_to_invoice_qty/migrations/15.0.2.0.1/post-fix-old-field-value.py
diff --git a/sale_line_refund_to_invoice_qty/__manifest__.py b/sale_line_refund_to_invoice_qty/__manifest__.py
index 15a5cceb2cc..66aa858d0ae 100644
--- a/sale_line_refund_to_invoice_qty/__manifest__.py
+++ b/sale_line_refund_to_invoice_qty/__manifest__.py
@@ -4,7 +4,7 @@
"name": "Sale Line Refund To Invoice Qty",
"summary": """Allow deciding whether refunded quantity should be considered
as quantity to reinvoice""",
- "version": "15.0.2.0.1",
+ "version": "16.0.1.0.0",
"category": "Sales",
"website": "https://github.com/OCA/account-invoicing",
"author": "ForgeFlow, Odoo Community Association (OCA)",
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/migrations/15.0.2.0.1/post-fix-old-field-value.py b/sale_line_refund_to_invoice_qty/migrations/15.0.2.0.1/post-fix-old-field-value.py
deleted file mode 100644
index 091f7210db9..00000000000
--- a/sale_line_refund_to_invoice_qty/migrations/15.0.2.0.1/post-fix-old-field-value.py
+++ /dev/null
@@ -1,60 +0,0 @@
-import logging
-
-from odoo import SUPERUSER_ID, api
-
-_logger = logging.getLogger(__name__)
-
-
-def migrate(cr, version):
- env = api.Environment(cr, SUPERUSER_ID, {})
- sol_model = env["sale.order.line"]
- field_definition = env["ir.model.fields"].search(
- [("name", "=", "sale_qty_to_reinvoice"), ("model", "=", "account.move.line")],
- limit=1,
- )
- if field_definition:
- env.cr.execute(
- """
- update account_move_line set sale_qty_to_reinvoice = True
- where create_date <= %s and
- (sale_qty_to_reinvoice = False or sale_qty_to_reinvoice is null)
- """,
- (field_definition.create_date or field_definition.write_date,),
- )
- env.cr.commit()
- query = """
- with invoice_lines as (
- select rel.order_line_id, sum(coalesce(aml.quantity, 0)) as quantity
- from account_move_line as aml
- inner join account_move as am on am.id = aml.move_id
- inner join sale_order_line_invoice_rel as rel on rel.invoice_line_id = aml.id
- where am.state = 'posted' and am.move_type = 'out_invoice'
- group by rel.order_line_id
- ), credit_lines as (
- select rel.order_line_id, sum(coalesce(aml.quantity, 0)) as quantity
- from account_move_line as aml
- inner join account_move as am on am.id = aml.move_id
- inner join sale_order_line_invoice_rel as rel on rel.invoice_line_id = aml.id
- where am.state = 'posted' and am.move_type = 'out_refund'
- and aml.sale_qty_to_reinvoice = true
- group by rel.order_line_id
- )
- select
- sol.id
- from sale_order_line as sol
- inner join sale_order as so on so.id = sol.order_id and so.state in ('sale', 'done')
- left join invoice_lines as il on sol.id = il.order_line_id
- left join credit_lines as cl on sol.id = cl.order_line_id
- where (coalesce(il.quantity, 0) - coalesce(cl.quantity, 0)) != sol.qty_invoiced
-
- """
- env.cr.execute(query)
- lines_with_problems = [data[0] for data in env.cr.fetchall()]
- if lines_with_problems:
- _logger.debug("total lines to reprocess: %s", str(len(lines_with_problems)))
- sol_model.search(
- [
- ("id", "in", lines_with_problems),
- ("product_id.type", "!=", "service"),
- ]
- )._compute_qty_invoiced()
diff --git a/sale_line_refund_to_invoice_qty/models/account.py b/sale_line_refund_to_invoice_qty/models/account.py
index 2509a054145..061ad0b2a7f 100644
--- a/sale_line_refund_to_invoice_qty/models/account.py
+++ b/sale_line_refund_to_invoice_qty/models/account.py
@@ -1,28 +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 fields, models
+from odoo import api, fields, models
class AccountMove(models.Model):
_inherit = "account.move"
- def _reverse_move_vals(self, default_values, cancel=True):
+ @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
- move_vals = super(AccountMove, self)._reverse_move_vals(
- default_values, cancel=cancel
- )
+ res = super().copy(default=default)
sale_qty_to_reinvoice = self.env.context.get("sale_qty_to_reinvoice", False)
- for vals in move_vals["line_ids"]:
- vals[2].update({"sale_qty_to_reinvoice": sale_qty_to_reinvoice})
- return move_vals
+ 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(
- string="Sale qty to reinvoice",
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
index f43b2d71366..7624d257423 100644
--- a/sale_line_refund_to_invoice_qty/models/sale.py
+++ b/sale_line_refund_to_invoice_qty/models/sale.py
@@ -33,7 +33,8 @@ def _compute_qty_invoiced(self):
qty_invoiced += invoice_line.product_uom_id._compute_quantity(
invoice_line.quantity, line.product_uom
)
- line.qty_invoiced = qty_invoiced
+ if line.qty_invoiced != qty_invoiced:
+ line.qty_invoiced = qty_invoiced
return res
@api.depends(
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
index 34ca3b73101..4fbcc03e59f 100644
--- a/sale_line_refund_to_invoice_qty/wizards/account_move_reversal.py
+++ b/sale_line_refund_to_invoice_qty/wizards/account_move_reversal.py
@@ -14,7 +14,10 @@ class AccountMoveReversal(models.TransientModel):
)
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=self.sale_qty_to_reinvoice),
+ 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
index eca3f47d296..e4eec4b8738 100644
--- 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
@@ -8,7 +8,7 @@