diff --git a/NEWS.rst b/NEWS.rst index ceb5fe5f24558f7c265b14b319ad0744eb70140b_TkVXUy5yc3Q=..6044da7611c2e29fef2ed0a6f5c303d2e8e54be6_TkVXUy5yc3Q= 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -2,6 +2,12 @@ Changelog ========= +13.0.1.6.1 +---------- + +On invoice refunding with new invoice, ensure that the new invoice is opened in +a form view corresponding to its invoice type. + 13.0.1.6.0 ---------- diff --git a/__manifest__.py b/__manifest__.py index ceb5fe5f24558f7c265b14b319ad0744eb70140b_X19tYW5pZmVzdF9fLnB5..6044da7611c2e29fef2ed0a6f5c303d2e8e54be6_X19tYW5pZmVzdF9fLnB5 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -22,7 +22,7 @@ "name": "Accounting Periods", "license": "AGPL-3", "summary": "Add period accounting concept", - "version": "13.0.1.6.0", + "version": "13.0.1.6.1", "category": "Accounting/Accounting", "author": "XCG Consulting", "website": "https://odoo.consulting/", diff --git a/wizards/__init__.py b/wizards/__init__.py index ceb5fe5f24558f7c265b14b319ad0744eb70140b_d2l6YXJkcy9fX2luaXRfXy5weQ==..6044da7611c2e29fef2ed0a6f5c303d2e8e54be6_d2l6YXJkcy9fX2luaXRfXy5weQ== 100644 --- a/wizards/__init__.py +++ b/wizards/__init__.py @@ -1,1 +1,1 @@ -from . import account_period_close # noqa: F401 +from . import account_move_reversal, account_period_close # noqa: F401 diff --git a/wizards/account_move_reversal.py b/wizards/account_move_reversal.py new file mode 100644 index 0000000000000000000000000000000000000000..6044da7611c2e29fef2ed0a6f5c303d2e8e54be6_d2l6YXJkcy9hY2NvdW50X21vdmVfcmV2ZXJzYWwucHk= --- /dev/null +++ b/wizards/account_move_reversal.py @@ -0,0 +1,53 @@ +############################################################################## +# +# Accounting periods, for Odoo +# Copyright (C) 2024 XCG Consulting <http://odoo.consulting> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from odoo import models + + +class AccountMoveReversal(models.TransientModel): + """Override to: + - On invoice refunding with new invoice, ensure that the new invoice is + opened in a form view corresponding to its invoice type. + """ + + _inherit = "account.move.reversal" + + def reverse_moves(self): + """Override to: + - On invoice refunding with new invoice, ensure that the new invoice is + opened in a form view corresponding to its invoice type. + """ + + action = super().reverse_moves() + + # On invoice refunding with new invoice, ensure that the new invoice is + # opened in a form view corresponding to its invoice type. + if self.refund_method == "modify": + + if "res_id" in action: + first_invoice_id = action["res_id"] + else: + first_invoice_id = action["domain"][0][2][0] + + first_invoice = self.env["account.move"].browse(first_invoice_id) + + action["context"] = dict(default_type=first_invoice.type) + + return action