Skip to content

Commit

Permalink
Merge PR #1461 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by AaronHForgeFlow
  • Loading branch information
OCA-git-bot committed Aug 7, 2023
2 parents 9089117 + 4502e3c commit 14a9c5b
Show file tree
Hide file tree
Showing 22 changed files with 956 additions and 0 deletions.
88 changes: 88 additions & 0 deletions sale_line_refund_to_invoice_qty/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/account-invoicing/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 <https://github.com/OCA/account-invoicing/issues/new?body=module:%20sale_line_refund_to_invoice_qty%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* ForgeFlow

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

* Jordi Masvidal <jordi.masvidal@forgeflow.com>
* Lois Rilo <lois.rilo@forgeflow.com>

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 <https://github.com/OCA/account-invoicing/tree/15.0/sale_line_refund_to_invoice_qty>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 5 additions & 0 deletions sale_line_refund_to_invoice_qty/__init__.py
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions sale_line_refund_to_invoice_qty/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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",
],
}
70 changes: 70 additions & 0 deletions sale_line_refund_to_invoice_qty/i18n/es.po
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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 ""
4 changes: 4 additions & 0 deletions sale_line_refund_to_invoice_qty/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions sale_line_refund_to_invoice_qty/models/account.py
Original file line number Diff line number Diff line change
@@ -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,
)
58 changes: 58 additions & 0 deletions sale_line_refund_to_invoice_qty/models/sale.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions sale_line_refund_to_invoice_qty/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Jordi Masvidal <jordi.masvidal@forgeflow.com>
* Lois Rilo <lois.rilo@forgeflow.com>
4 changes: 4 additions & 0 deletions sale_line_refund_to_invoice_qty/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 7 additions & 0 deletions sale_line_refund_to_invoice_qty/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 14a9c5b

Please sign in to comment.