mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[FIX] 12.0 make account_payment_order_inbound test multicompany resilient
This commit is contained in:
@@ -99,6 +99,7 @@ Contributors
|
||||
* Jose María Alzaga <jose.alzaga@aselcis.com>
|
||||
* Meyomesse Gilles <meyomesse.gilles@gmail.com>
|
||||
* Carlos Dauden
|
||||
* Pieter Paulussen <pieterpaulussen@code-source.be>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
@@ -21,7 +21,9 @@ class TestPaymentOrderInboundBase(SavepointCase):
|
||||
'account.data_account_type_revenue').id)],
|
||||
limit=1).id
|
||||
self.journal = self.env['account.journal'].search(
|
||||
[('type', '=', 'bank')], limit=1
|
||||
[('type', '=', 'bank'),
|
||||
'|', ('company_id', '=', self.env.user.company_id.id),
|
||||
('company_id', '=', False)], limit=1
|
||||
)
|
||||
self.inbound_mode.variable_journal_ids = self.journal
|
||||
# Make sure no others orders are present
|
||||
@@ -85,13 +87,11 @@ class TestPaymentOrderInbound(TestPaymentOrderInboundBase):
|
||||
def test_creation(self):
|
||||
payment_order = self.inbound_order
|
||||
self.assertEqual(len(payment_order.ids), 1)
|
||||
bank_journal = self.env['account.journal'].search(
|
||||
[('type', '=', 'bank')], limit=1)
|
||||
# Set journal to allow cancelling entries
|
||||
bank_journal.update_posted = True
|
||||
self.journal.update_posted = True
|
||||
|
||||
payment_order.write({
|
||||
'journal_id': bank_journal.id,
|
||||
'journal_id': self.journal.id,
|
||||
})
|
||||
|
||||
self.assertEqual(len(payment_order.payment_line_ids), 1)
|
||||
|
||||
@@ -11,9 +11,6 @@ class TestPaymentOrderOutbound(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestPaymentOrderOutbound, self).setUp()
|
||||
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)],
|
||||
@@ -22,10 +19,21 @@ class TestPaymentOrderOutbound(TransactionCase):
|
||||
self.invoice_02 = self._create_supplier_invoice()
|
||||
self.mode = self.env.ref(
|
||||
'account_payment_mode.payment_mode_outbound_ct1')
|
||||
self.mode.default_journal_ids = self.env['account.journal'].search([
|
||||
('type', 'in', ('purchase', 'purchase_refund')),
|
||||
('company_id', '=', self.env.user.company_id.id)
|
||||
])
|
||||
self.creation_mode = self.env.ref(
|
||||
'account_payment_mode.payment_mode_outbound_dd1')
|
||||
self.creation_mode.default_journal_ids = (
|
||||
self.env['account.journal'].search([
|
||||
('type', 'in', ('sale', 'sale_refund')),
|
||||
('company_id', '=', self.env.user.company_id.id)
|
||||
]))
|
||||
self.bank_journal = self.env['account.journal'].search(
|
||||
[('type', '=', 'bank')], limit=1)
|
||||
[('type', '=', 'bank'),
|
||||
'|', ('company_id', '=', self.env.user.company_id.id),
|
||||
('company_id', '=', False)], limit=1)
|
||||
# Make sure no other payment orders are in the DB
|
||||
self.domain = [
|
||||
('state', '=', 'draft'),
|
||||
@@ -144,13 +152,11 @@ class TestPaymentOrderOutbound(TransactionCase):
|
||||
|
||||
payment_order = self.env['account.payment.order'].search(self.domain)
|
||||
self.assertEqual(len(payment_order), 1)
|
||||
bank_journal = self.env['account.journal'].search(
|
||||
[('type', '=', 'bank')], limit=1)
|
||||
# Set journal to allow cancelling entries
|
||||
bank_journal.update_posted = True
|
||||
self.bank_journal.update_posted = True
|
||||
|
||||
payment_order.write({
|
||||
'journal_id': bank_journal.id,
|
||||
'journal_id': self.bank_journal.id,
|
||||
})
|
||||
|
||||
self.assertEqual(len(payment_order.payment_line_ids), 1)
|
||||
@@ -185,7 +191,7 @@ class TestPaymentOrderOutbound(TransactionCase):
|
||||
outbound_order = self.env['account.payment.order'].create({
|
||||
'payment_type': 'outbound',
|
||||
'payment_mode_id': self.mode.id,
|
||||
'journal_id': self.journal.id,
|
||||
'journal_id': self.bank_journal.id,
|
||||
})
|
||||
with self.assertRaises(ValidationError):
|
||||
outbound_order.date_scheduled = date.today() - timedelta(
|
||||
|
||||
Reference in New Issue
Block a user