Skip to content

Commit

Permalink
[MIG] account_invoice_refund_link: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andrel-exo committed Apr 21, 2024
1 parent 8af8727 commit f2c12d9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion account_invoice_refund_link/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{
"name": "Show links between refunds and their originator invoices.",
"version": "16.0.1.0.4",
"version": "17.0.1.0.0",
"development_status": "Mature",
"category": "Accounting & Finance",
"website": "https://github.com/OCA/account-invoicing",
Expand Down
5 changes: 1 addition & 4 deletions account_invoice_refund_link/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# Copyright 2017-2018 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import SUPERUSER_ID, api


def match_origin_lines(refund):
"""Try to match lines by product or by description."""
Expand All @@ -24,8 +22,7 @@ def match_origin_lines(refund):
break


def post_init_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
def post_init_hook(env):
# Linking all refund invoices to its original invoices
refunds = env["account.move"].search(
[
Expand Down
13 changes: 6 additions & 7 deletions account_invoice_refund_link/tests/test_invoice_refund_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class TestInvoiceRefundLinkBase(TransactionCase):
refund_method = "refund"
is_modify = False

@classmethod
def setUpClass(cls):
Expand Down Expand Up @@ -84,11 +84,10 @@ def setUpClass(cls):
active_ids=cls.invoice.ids, active_model="account.move"
).create(
{
"refund_method": cls.refund_method,
"reason": cls.refund_reason,
"journal_id": cls.journal.id,
}
).reverse_moves()
).reverse_moves(is_modify=cls.is_modify)

def _test_refund_link(self):
self.assertTrue(self.invoice.refund_invoice_ids)
Expand Down Expand Up @@ -118,7 +117,7 @@ def test_post_init_hook(self):
refund = self.invoice.refund_invoice_ids[0]
refund.invoice_line_ids.write({"origin_line_id": False})
self.assertFalse(refund.mapped("invoice_line_ids.origin_line_id"))
post_init_hook(self.env.cr, None)
post_init_hook(self.env)
self.refund_reason = "The refund reason"
self._test_refund_link()

Expand All @@ -140,15 +139,15 @@ def test_refund_copy(self):
)


class TestInvoiceRefundCancelLink(TestInvoiceRefundLinkBase):
refund_method = "cancel"
class TestInvoiceRefundNoModifyLink(TestInvoiceRefundLinkBase):
is_modify = False

def test_refund_link(self):
self._test_refund_link()


class TestInvoiceRefundModifyLink(TestInvoiceRefundLinkBase):
refund_method = "modify"
is_modify = True

def test_refund_link(self):
self._test_refund_link()
12 changes: 4 additions & 8 deletions account_invoice_refund_link/views/account_invoice_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
<page
name="refunds"
string="Refunds"
attrs="{'invisible':[('move_type', 'not in', ['in_invoice', 'out_invoice'])]}"
invisible="move_type not in ('in_invoice', 'out_invoice')"
>
<field name="refund_invoice_ids" nolabel="1">
<tree
decoration-info="state == 'draft'"
decoration-muted="state == 'cancel'"
>
<field name="partner_id" invisible="1" />
<field name="move_type" invisible="1" />
<field name="partner_id" column_invisible="1" />
<field name="move_type" column_invisible="1" />
<field name="invoice_date" />
<field name="name" />
<field name="invoice_origin" />
Expand Down Expand Up @@ -68,11 +68,7 @@
name="reversed_entry_id"
string="Invoice reference"
readonly="1"
attrs="{'invisible': [
'|',
('reversed_entry_id', '=', False),
('move_type', 'not in', ('in_refund', 'out_refund'))
]}"
invisible="not reversed_entry_id or move_type not in ('in_refund', 'out_refund')"
/>
</field>
</field>
Expand Down
4 changes: 2 additions & 2 deletions account_invoice_refund_link/wizards/account_move_reversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
class AccountMoveReversal(models.TransientModel):
_inherit = "account.move.reversal"

def reverse_moves(self):
def reverse_moves(self, is_modify=False):
"""
Only link invoice lines with theirs original lines when the reversal
move has been done from reversal wizard.
"""
return super(
AccountMoveReversal, self.with_context(link_origin_line=True)
).reverse_moves()
).reverse_moves(is_modify=is_modify)

0 comments on commit f2c12d9

Please sign in to comment.