mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[MIG] account_payment_order: Migration to 15.0
This commit is contained in:
committed by
Pedro M. Baeza
parent
ed5c2d0c3f
commit
ad9f376b29
@@ -1,7 +1,9 @@
|
||||
# Copyright 2019 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from odoo.addons.account.models.account_payment_method import AccountPaymentMethod
|
||||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||
|
||||
|
||||
@@ -9,6 +11,18 @@ class TestAccountPayment(AccountTestInvoicingCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls, chart_template_ref=None):
|
||||
super().setUpClass(chart_template_ref=chart_template_ref)
|
||||
|
||||
Method_get_payment_method_information = (
|
||||
AccountPaymentMethod._get_payment_method_information
|
||||
)
|
||||
|
||||
def _get_payment_method_information(self):
|
||||
res = Method_get_payment_method_information(self)
|
||||
res["IN"] = {"mode": "multi", "domain": [("type", "=", "bank")]}
|
||||
res["IN2"] = {"mode": "multi", "domain": [("type", "=", "bank")]}
|
||||
res["OUT"] = {"mode": "multi", "domain": [("type", "=", "bank")]}
|
||||
return res
|
||||
|
||||
cls.company = cls.company_data["company"]
|
||||
cls.env.user.company_ids += cls.company
|
||||
|
||||
@@ -19,38 +33,38 @@ class TestAccountPayment(AccountTestInvoicingCommon):
|
||||
|
||||
# INSTANCES
|
||||
# Payment methods
|
||||
cls.inbound_payment_method_01 = cls.payment_method_model.create(
|
||||
{
|
||||
"name": "inbound",
|
||||
"code": "IN",
|
||||
"payment_type": "inbound",
|
||||
}
|
||||
)
|
||||
cls.inbound_payment_method_02 = cls.inbound_payment_method_01.copy(
|
||||
{
|
||||
"name": "inbound 2",
|
||||
"code": "IN2",
|
||||
}
|
||||
)
|
||||
cls.outbound_payment_method_01 = cls.payment_method_model.create(
|
||||
{
|
||||
"name": "outbound",
|
||||
"code": "OUT",
|
||||
"payment_type": "outbound",
|
||||
}
|
||||
)
|
||||
# Journals
|
||||
cls.bank_journal = cls.company_data["default_journal_bank"]
|
||||
cls.bank_journal.inbound_payment_method_ids = [
|
||||
(
|
||||
6,
|
||||
0,
|
||||
[cls.inbound_payment_method_01.id, cls.inbound_payment_method_02.id],
|
||||
with patch.object(
|
||||
AccountPaymentMethod,
|
||||
"_get_payment_method_information",
|
||||
_get_payment_method_information,
|
||||
):
|
||||
|
||||
cls.inbound_payment_method_01 = cls.payment_method_model.create(
|
||||
{
|
||||
"name": "inbound",
|
||||
"code": "IN",
|
||||
"payment_type": "inbound",
|
||||
}
|
||||
)
|
||||
]
|
||||
cls.bank_journal.outbound_payment_method_ids = [
|
||||
(6, 0, [cls.outbound_payment_method_01.id])
|
||||
]
|
||||
cls.inbound_payment_method_02 = cls.inbound_payment_method_01.copy(
|
||||
{
|
||||
"name": "inbound 2",
|
||||
"code": "IN2",
|
||||
"payment_type": "inbound",
|
||||
}
|
||||
)
|
||||
cls.outbound_payment_method_01 = cls.payment_method_model.create(
|
||||
{
|
||||
"name": "outbound",
|
||||
"code": "OUT",
|
||||
"payment_type": "outbound",
|
||||
}
|
||||
)
|
||||
# Journals
|
||||
cls.manual_in = cls.env.ref("account.account_payment_method_manual_in")
|
||||
cls.manual_out = cls.env.ref("account.account_payment_method_manual_out")
|
||||
|
||||
cls.bank_journal = cls.company_data["default_journal_bank"]
|
||||
|
||||
def test_account_payment_01(self):
|
||||
self.assertFalse(self.inbound_payment_method_01.payment_order_only)
|
||||
@@ -63,6 +77,7 @@ class TestAccountPayment(AccountTestInvoicingCommon):
|
||||
self.inbound_payment_method_02.payment_order_only = True
|
||||
self.assertTrue(self.inbound_payment_method_01.payment_order_only)
|
||||
self.assertTrue(self.inbound_payment_method_02.payment_order_only)
|
||||
self.manual_in.payment_order_only = True
|
||||
self.assertTrue(self.bank_journal.inbound_payment_order_only)
|
||||
|
||||
def test_account_payment_02(self):
|
||||
@@ -70,6 +85,11 @@ class TestAccountPayment(AccountTestInvoicingCommon):
|
||||
self.assertFalse(self.bank_journal.outbound_payment_order_only)
|
||||
self.outbound_payment_method_01.payment_order_only = True
|
||||
self.assertTrue(self.outbound_payment_method_01.payment_order_only)
|
||||
|
||||
payment_method_id = (
|
||||
self.bank_journal.outbound_payment_method_line_ids.payment_method_id
|
||||
)
|
||||
payment_method_id.payment_order_only = True
|
||||
self.assertTrue(self.bank_journal.outbound_payment_order_only)
|
||||
|
||||
def test_account_payment_03(self):
|
||||
@@ -90,7 +110,13 @@ class TestAccountPayment(AccountTestInvoicingCommon):
|
||||
journals = new_account_payment._get_default_journal()
|
||||
self.assertIn(self.bank_journal, journals)
|
||||
# check payment methods
|
||||
payment_methods = new_account_payment.available_payment_method_ids.ids
|
||||
payment_methods = (
|
||||
new_account_payment.available_payment_method_line_ids.filtered(
|
||||
lambda x: x.payment_type == "inbound"
|
||||
)
|
||||
.mapped("payment_method_id")
|
||||
.ids
|
||||
)
|
||||
self.assertIn(self.inbound_payment_method_01.id, payment_methods)
|
||||
self.assertIn(self.inbound_payment_method_02.id, payment_methods)
|
||||
# Set one payment method of the bank journal 'payment order only'
|
||||
@@ -99,20 +125,43 @@ class TestAccountPayment(AccountTestInvoicingCommon):
|
||||
journals = new_account_payment._get_default_journal()
|
||||
self.assertIn(self.bank_journal, journals)
|
||||
# check payment methods
|
||||
new_account_payment._compute_payment_method_fields()
|
||||
payment_methods = new_account_payment.available_payment_method_ids.ids
|
||||
new_account_payment2 = self.account_payment_model.with_context(
|
||||
default_company_id=self.company.id
|
||||
).new(
|
||||
{
|
||||
"journal_id": self.bank_journal.id,
|
||||
"payment_type": "inbound",
|
||||
"amount": 1,
|
||||
"company_id": self.company.id,
|
||||
}
|
||||
)
|
||||
payment_methods = new_account_payment2.available_payment_method_line_ids.mapped(
|
||||
"payment_method_id"
|
||||
).ids
|
||||
self.assertNotIn(self.inbound_payment_method_01.id, payment_methods)
|
||||
self.assertIn(self.inbound_payment_method_02.id, payment_methods)
|
||||
# Set all payment methods of the bank journal 'payment order only'
|
||||
self.inbound_payment_method_02.payment_order_only = True
|
||||
self.assertTrue(self.inbound_payment_method_01.payment_order_only)
|
||||
self.assertTrue(self.inbound_payment_method_02.payment_order_only)
|
||||
self.manual_in.payment_order_only = True
|
||||
self.assertTrue(self.bank_journal.inbound_payment_order_only)
|
||||
# check journals
|
||||
journals = new_account_payment._get_default_journal()
|
||||
self.assertNotIn(self.bank_journal, journals)
|
||||
# check payment methods
|
||||
new_account_payment._compute_payment_method_fields()
|
||||
payment_methods = new_account_payment.available_payment_method_ids.ids
|
||||
new_account_payment3 = self.account_payment_model.with_context(
|
||||
default_company_id=self.company.id
|
||||
).new(
|
||||
{
|
||||
"journal_id": self.bank_journal.id,
|
||||
"payment_type": "inbound",
|
||||
"amount": 1,
|
||||
"company_id": self.company.id,
|
||||
}
|
||||
)
|
||||
payment_methods = new_account_payment3.available_payment_method_line_ids.mapped(
|
||||
"payment_method_id"
|
||||
).ids
|
||||
self.assertNotIn(self.inbound_payment_method_01.id, payment_methods)
|
||||
self.assertNotIn(self.inbound_payment_method_02.id, payment_methods)
|
||||
|
||||
@@ -1,13 +1,28 @@
|
||||
# © 2017 Creu Blanca
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
from odoo.addons.account.models.account_payment_method import AccountPaymentMethod
|
||||
|
||||
|
||||
class TestPaymentMode(TransactionCase):
|
||||
def setUp(self):
|
||||
super(TestPaymentMode, self).setUp()
|
||||
|
||||
Method_get_payment_method_information = (
|
||||
AccountPaymentMethod._get_payment_method_information
|
||||
)
|
||||
|
||||
def _get_payment_method_information(self):
|
||||
res = Method_get_payment_method_information(self)
|
||||
res["IN"] = {"mode": "multi", "domain": [("type", "=", "bank")]}
|
||||
res["IN2"] = {"mode": "multi", "domain": [("type", "=", "bank")]}
|
||||
res["electronic_out"] = {"mode": "multi", "domain": [("type", "=", "bank")]}
|
||||
return res
|
||||
|
||||
# Company
|
||||
self.company = self.env.ref("base.main_company")
|
||||
|
||||
@@ -28,13 +43,19 @@ class TestPaymentMode(TransactionCase):
|
||||
|
||||
self.manual_in = self.env.ref("account.account_payment_method_manual_in")
|
||||
|
||||
self.electronic_out = self.env["account.payment.method"].create(
|
||||
{
|
||||
"name": "Electronic Out",
|
||||
"code": "electronic_out",
|
||||
"payment_type": "outbound",
|
||||
}
|
||||
)
|
||||
with patch.object(
|
||||
AccountPaymentMethod,
|
||||
"_get_payment_method_information",
|
||||
_get_payment_method_information,
|
||||
):
|
||||
|
||||
self.electronic_out = self.env["account.payment.method"].create(
|
||||
{
|
||||
"name": "Electronic Out",
|
||||
"code": "electronic_out",
|
||||
"payment_type": "outbound",
|
||||
}
|
||||
)
|
||||
|
||||
self.payment_mode_c1 = self.env["account.payment.mode"].create(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user