Skip to content

Commit

Permalink
[MIG] sale_line_refund_to_invoice_qty: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Iniesta committed May 29, 2023
1 parent baea072 commit fbea4b5
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 19 deletions.
2 changes: 1 addition & 1 deletion sale_line_refund_to_invoice_qty/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "16.0.1.0.0",
"category": "Sales",
"website": "https://github.com/OCA/account-invoicing",
"author": "ForgeFlow, Odoo Community Association (OCA)",
Expand Down
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"
17 changes: 8 additions & 9 deletions sale_line_refund_to_invoice_qty/models/account.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
# 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
)
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})
return move_vals
res = super().copy(default=default)
if self.env.context.get("sale_qty_to_reinvoice"):
res.line_ids.write({"sale_qty_to_reinvoice": True})
return res


class AccountMoveLine(models.Model):
_inherit = "account.move.line"

sale_qty_to_reinvoice = fields.Boolean(
help="Leave it marked if you will reinvoice the same sale order line",
copy=False,
)
18 changes: 9 additions & 9 deletions sale_line_refund_to_invoice_qty/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ 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
if line.qty_to_invoice != qty_invoiced:
line.qty_invoiced = qty_invoiced
return res

@api.depends(
Expand Down
1 change: 1 addition & 0 deletions sale_line_refund_to_invoice_qty/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* Jordi Masvidal <[email protected]>
* Javier Iniesta <[email protected]>

0 comments on commit fbea4b5

Please sign in to comment.