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 Jul 18, 2023
1 parent 632c52c commit 4502e3c
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 73 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.2.0.1",
"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"

This file was deleted.

16 changes: 7 additions & 9 deletions sale_line_refund_to_invoice_qty/models/account.py
Original file line number Diff line number Diff line change
@@ -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,
)
3 changes: 2 additions & 1 deletion sale_line_refund_to_invoice_qty/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<xpath expr="//field[@name='journal_id']/.." position="after">
<group
name="sale_line_refund_qty"
attrs="{'invisible': [('move_type', '!=', 'out_invoice')]}"
attrs="{'invisible': ['|', ('move_type', '!=', 'out_invoice'), ('refund_method', '=', 'modify')]}"
>
<field name="sale_qty_to_reinvoice" />
<div class="oe_grey" colspan="4">
Expand Down

0 comments on commit 4502e3c

Please sign in to comment.