mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[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:
committed by
Pedro M. Baeza
parent
16274598ac
commit
735fcfbee4
@@ -8,7 +8,7 @@
|
||||
|
||||
{
|
||||
"name": "Account Payment Order",
|
||||
"version": "14.0.1.0.0",
|
||||
"version": "14.0.1.0.2",
|
||||
"license": "AGPL-3",
|
||||
"author": "ACSONE SA/NV, "
|
||||
"Therp BV, "
|
||||
|
||||
@@ -14,25 +14,28 @@ 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"
|
||||
)
|
||||
self.invoice_line_account = self.env["account.account"].search(
|
||||
[
|
||||
(
|
||||
"user_type_id",
|
||||
"=",
|
||||
self.env.ref("account.data_account_type_revenue").id,
|
||||
)
|
||||
],
|
||||
limit=1,
|
||||
self.invoice_line_account = self.env["account.account"].create(
|
||||
{
|
||||
"name": "Test account",
|
||||
"code": "TEST1",
|
||||
"user_type_id": self.env.ref("account.data_account_type_revenue").id,
|
||||
}
|
||||
)
|
||||
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
|
||||
@@ -62,6 +65,7 @@ class TestPaymentOrderInboundBase(SavepointCase):
|
||||
invoice_line_form.quantity = 1
|
||||
invoice_line_form.price_unit = 100.0
|
||||
invoice_line_form.account_id = self.invoice_line_account
|
||||
invoice_line_form.tax_ids.clear()
|
||||
invoice = invoice_form.save()
|
||||
invoice_form = Form(invoice)
|
||||
invoice_form.payment_mode_id = self.inbound_mode
|
||||
|
||||
@@ -11,22 +11,16 @@ 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
|
||||
)
|
||||
self.invoice_line_account = (
|
||||
self.env["account.account"]
|
||||
.search(
|
||||
[
|
||||
(
|
||||
"user_type_id",
|
||||
"=",
|
||||
self.env.ref("account.data_account_type_expenses").id,
|
||||
)
|
||||
],
|
||||
limit=1,
|
||||
)
|
||||
.id
|
||||
self.invoice_line_account = self.env["account.account"].create(
|
||||
{
|
||||
"name": "Test account",
|
||||
"code": "TEST1",
|
||||
"user_type_id": self.env.ref("account.data_account_type_expenses").id,
|
||||
}
|
||||
)
|
||||
self.invoice = self._create_supplier_invoice()
|
||||
self.invoice_02 = self._create_supplier_invoice()
|
||||
@@ -35,10 +29,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):
|
||||
@@ -58,7 +57,7 @@ class TestPaymentOrderOutbound(TransactionCase):
|
||||
"quantity": 1.0,
|
||||
"price_unit": 100.0,
|
||||
"name": "product that cost 100",
|
||||
"account_id": self.invoice_line_account,
|
||||
"account_id": self.invoice_line_account.id,
|
||||
},
|
||||
)
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user