diff --git a/account_invoice_refund_link/__manifest__.py b/account_invoice_refund_link/__manifest__.py index 7d94cd324a2d..3debe24f35f3 100644 --- a/account_invoice_refund_link/__manifest__.py +++ b/account_invoice_refund_link/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Show links between refunds and their originator invoices.", - "version": "15.0.1.0.1", + "version": "16.0.1.0.0", "development_status": "Mature", "category": "Accounting & Finance", "website": "https://github.com/OCA/account-invoicing", diff --git a/account_invoice_refund_link/models/account_move.py b/account_invoice_refund_link/models/account_move.py index 58345ae28375..1659a4aa8d28 100644 --- a/account_invoice_refund_link/models/account_move.py +++ b/account_invoice_refund_link/models/account_move.py @@ -3,7 +3,7 @@ # Copyright 2014-2022 Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models +from odoo import fields, models class AccountMove(models.Model): @@ -13,21 +13,20 @@ class AccountMove(models.Model): "account.move", "reversed_entry_id", string="Refund Invoices", readonly=True ) - @api.model - def _reverse_move_vals(self, default_values, cancel=True): - move_vals = super()._reverse_move_vals(default_values, cancel) - if self.env.context.get("link_origin_line", False) and move_vals[ - "move_type" - ] in ( - "out_refund", - "in_refund", - ): - refund_lines_vals = [ - x[2] - for x in move_vals.get("line_ids", []) - if not x[2].get("exclude_from_invoice_tab", True) - ] - for i, line in enumerate(self.invoice_line_ids): - if i < len(refund_lines_vals): - refund_lines_vals[i]["origin_line_id"] = line.id - return move_vals + def _reverse_moves(self, default_values_list=None, cancel=False): + reverse_moves = super()._reverse_moves( + default_values_list=default_values_list, cancel=cancel + ) + if self.env.context.get("link_origin_line", False): + for move in reverse_moves: + if move.move_type in ( + "out_refund", + "in_refund", + ): + refund_lines = move.line_ids.filtered( + lambda x: x.display_type == "product" + ) + for i, line in enumerate(self.invoice_line_ids): + if i < len(refund_lines): + refund_lines[i].origin_line_id = line.id + return reverse_moves diff --git a/account_invoice_refund_link/tests/test_invoice_refund_link.py b/account_invoice_refund_link/tests/test_invoice_refund_link.py index bab5a06333ce..6ff9d5e46c96 100644 --- a/account_invoice_refund_link/tests/test_invoice_refund_link.py +++ b/account_invoice_refund_link/tests/test_invoice_refund_link.py @@ -18,9 +18,7 @@ def setUpClass(cls): { "name": "TESTACC", "code": "TESTACC", - "user_type_id": cls.env.ref( - "account.data_account_type_other_income" - ).id, + "account_type": "income", "deprecated": False, "company_id": cls.env.user.company_id.id, } diff --git a/setup/account_invoice_refund_link/odoo/addons/account_invoice_refund_link b/setup/account_invoice_refund_link/odoo/addons/account_invoice_refund_link new file mode 120000 index 000000000000..dd7a70be7e50 --- /dev/null +++ b/setup/account_invoice_refund_link/odoo/addons/account_invoice_refund_link @@ -0,0 +1 @@ +../../../../account_invoice_refund_link \ No newline at end of file diff --git a/setup/account_invoice_refund_link/setup.py b/setup/account_invoice_refund_link/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/account_invoice_refund_link/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)