[FIX] account_payment_order: Fix tests

On multi-company settings, we need to make sure we are searching and creating objects with the correct company associated.

TT28423
This commit is contained in:
João Marques
2021-02-25 09:51:14 +00:00
committed by Marçal Isern
parent 5ee866755b
commit f41cf5516d
2 changed files with 20 additions and 6 deletions

View File

@@ -14,6 +14,7 @@ class TestPaymentOrderInboundBase(SavepointCase):
def setUpClass(cls):
self = cls
super().setUpClass()
self.env.user.company_id = self.env.ref("base.main_company").id
self.inbound_mode = self.env.ref(
"account_payment_mode.payment_mode_inbound_dd1"
)
@@ -23,16 +24,22 @@ class TestPaymentOrderInboundBase(SavepointCase):
"user_type_id",
"=",
self.env.ref("account.data_account_type_revenue").id,
)
),
("company_id", "=", self.env.user.company_id.id),
],
limit=1,
)
self.journal = self.env["account.journal"].search(
[("type", "=", "bank")], limit=1
[("type", "=", "bank"), ("company_id", "=", self.env.user.company_id.id)],
limit=1,
)
self.inbound_mode.variable_journal_ids = self.journal
# Make sure no others orders are present
self.domain = [("state", "=", "draft"), ("payment_type", "=", "inbound")]
self.domain = [
("state", "=", "draft"),
("payment_type", "=", "inbound"),
("company_id", "=", self.env.user.company_id.id),
]
self.payment_order_obj = self.env["account.payment.order"]
self.payment_order_obj.search(self.domain).unlink()
# Create payment order

View File

@@ -11,6 +11,7 @@ from odoo.tests.common import TransactionCase
class TestPaymentOrderOutbound(TransactionCase):
def setUp(self):
super(TestPaymentOrderOutbound, self).setUp()
self.env.user.company_id = self.env.ref("base.main_company").id
self.journal = self.env["account.journal"].search(
[("type", "=", "bank")], limit=1
)
@@ -22,7 +23,8 @@ class TestPaymentOrderOutbound(TransactionCase):
"user_type_id",
"=",
self.env.ref("account.data_account_type_expenses").id,
)
),
("company_id", "=", self.env.user.company_id.id),
],
limit=1,
)
@@ -35,10 +37,15 @@ class TestPaymentOrderOutbound(TransactionCase):
"account_payment_mode.payment_mode_outbound_dd1"
)
self.bank_journal = self.env["account.journal"].search(
[("type", "=", "bank")], limit=1
[("type", "=", "bank"), ("company_id", "=", self.env.user.company_id.id)],
limit=1,
)
# Make sure no other payment orders are in the DB
self.domain = [("state", "=", "draft"), ("payment_type", "=", "outbound")]
self.domain = [
("state", "=", "draft"),
("payment_type", "=", "outbound"),
("company_id", "=", self.env.user.company_id.id),
]
self.env["account.payment.order"].search(self.domain).unlink()
def _create_supplier_invoice(self):