From 541bfd8b9e7ff4c64cca86e26a0cba57aee7582a Mon Sep 17 00:00:00 2001 From: abdessamad salim Date: Thu, 6 Feb 2025 08:36:54 +0100 Subject: [PATCH] [MIG] account_payment_return: Migration to 18.0 --- .../models/payment_return.py | 8 +++---- .../tests/test_payment_return.py | 23 +++++++++++++------ .../views/payment_return_view.xml | 17 ++++++-------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/account_payment_return/models/payment_return.py b/account_payment_return/models/payment_return.py index 3d070bcdc87..2d4ff24efc4 100644 --- a/account_payment_return/models/payment_return.py +++ b/account_payment_return/models/payment_return.py @@ -6,9 +6,9 @@ # Copyright 2017 Tecnativa - Luis M. Ontalba # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import _, api, fields, models +from odoo import api, fields, models from odoo.exceptions import UserError, ValidationError - +from odoo.tools.translate import _ class PaymentReturn(models.Model): _name = "payment.return" @@ -71,7 +71,7 @@ class PaymentReturn(models.Model): def _check_duplicate_move_line(self): def append_error(error_line): error_list.append( - _( + self.env._( "Payment Line: %(move_names)s (%(partner_name)s) " "in Payment Return: %(return_name)s" ) @@ -157,7 +157,7 @@ def _prepare_move_line(self, move, total_amount): "debit": 0.0, "credit": total_amount, "account_id": self.payment_method_line_id.payment_account_id.id - or self.company_id.account_journal_payment_debit_account_id.id, + or self.company_id.account_journal_suspense_account_id.id, "move_id": move.id, "journal_id": move.journal_id.id, } diff --git a/account_payment_return/tests/test_payment_return.py b/account_payment_return/tests/test_payment_return.py index 12cd9919e1c..0afb9985d63 100644 --- a/account_payment_return/tests/test_payment_return.py +++ b/account_payment_return/tests/test_payment_return.py @@ -5,7 +5,7 @@ # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from odoo.exceptions import UserError, ValidationError -from odoo.tests.common import Form +from odoo.tests import Form from odoo.addons.base.tests.common import BaseCommon @@ -175,14 +175,23 @@ def test_find_match_invoice(self): def test_find_match_move_line(self): self.payment_line.name = "test match move line 001" - self.payment_return.line_ids.write( + self.payment_return.write( { - "partner_id": False, - "move_line_ids": [(6, 0, [])], - "amount": 0.0, - "reference": self.payment_line.name, + "line_ids": [ + ( + 0, + 0, + { + "partner_id": False, + "move_line_ids": [(6, 0, [])], + "amount": 0.0, + "reference": self.payment_line.name, + }, + ) + ] } ) + self.payment_return.button_match() self.assertEqual( self.payment_return.line_ids[0].partner_id.id, @@ -232,7 +241,7 @@ def test_payments_widget(self): self.assertEqual(len(info["content"]), 2) self.assertEqual(info["content"][1]["amount"], -500.0) - def test_reason_name_search(self): + def test_reason_search_display_name(self): reason = self.env["payment.return.reason"] line = self.payment_return.line_ids[0] line.reason_id = reason.name_search("RTEST")[0] diff --git a/account_payment_return/views/payment_return_view.xml b/account_payment_return/views/payment_return_view.xml index dbaa6b8e277..1470fbc287c 100644 --- a/account_payment_return/views/payment_return_view.xml +++ b/account_payment_return/views/payment_return_view.xml @@ -74,7 +74,7 @@ context="{'default_date': date}" readonly="state in ['cancelled', 'done']" > - + @@ -113,24 +113,21 @@ required="expense_account" optional="show" /> - + -
- - -
+ payment.return.tree payment.return - tree + list - + @@ -141,7 +138,7 @@ /> - + @@ -171,7 +168,7 @@ Customer Payment Returns payment.return - tree,form + list,form