Skip to content

Commit

Permalink
[MIG] account_payment_return: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
absal-smile committed Feb 7, 2025
1 parent 85fccc0 commit 541bfd8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
8 changes: 4 additions & 4 deletions account_payment_return/models/payment_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
)
Expand Down Expand Up @@ -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,
}
Expand Down
23 changes: 16 additions & 7 deletions account_payment_return/tests/test_payment_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down
17 changes: 7 additions & 10 deletions account_payment_return/views/payment_return_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
context="{'default_date': date}"
readonly="state in ['cancelled', 'done']"
>
<tree editable="top">
<list editable="top">
<field name="date" />
<field name="concept" />
<field name="reason_id" />
Expand Down Expand Up @@ -113,24 +113,21 @@
required="expense_account"
optional="show"
/>
</tree>
</list>
</field>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" />
<field name="message_ids" widget="mail_thread" />
</div>
<chatter />
</form>
</field>
</record>
<record model="ir.ui.view" id="payment_return_tree_view">
<field name="name">payment.return.tree</field>
<field name="model">payment.return</field>
<field name="type">tree</field>
<field name="type">list</field>
<field name="arch" type="xml">
<tree decoration-muted="state == 'cancelled'">
<list decoration-muted="state == 'cancelled'">
<field name="name" readonly="state in ['cancelled', 'done']" />
<field name="date" readonly="state in ['cancelled', 'done']" />
<field name="journal_id" readonly="state in ['cancelled', 'done']" />
Expand All @@ -141,7 +138,7 @@
/>
<field name="state" />
<field name="total_amount" sum="Total amount" />
</tree>
</list>
</field>
</record>
<record model="ir.ui.view" id="payment_return_search_view">
Expand Down Expand Up @@ -171,7 +168,7 @@
<record model="ir.actions.act_window" id="payment_return_action">
<field name="name">Customer Payment Returns</field>
<field name="res_model">payment.return</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
</record>
<menuitem
id="payment_return_menu"
Expand Down

0 comments on commit 541bfd8

Please sign in to comment.