[IMP] account: Remove test_control_journal_account dependency to AccountTestCommon
l10n runbot builds are all failing when running at least one test depending of AccountTestCommon because it: - doesn't create a sandboxed testing environnement to manage the multi-currency, multi-company, the default company's currency, the exchange rates... - doesn't setup a testing user then all tests are done using the superuser. - doesn't provide a fully setup chart of accounts: exchange difference journal is not set, accounts have bad types, etc... - is run sometimes at-install. --task: 2301180
This commit is contained in:
@@ -17,7 +17,6 @@ from . import test_account_move_partner_count
|
||||
from . import test_account_move_rounding
|
||||
from . import test_account_invoice_report
|
||||
from . import test_account_journal_dashboard
|
||||
from . import test_control_journal_account
|
||||
from . import test_fiscal_position
|
||||
from . import test_reconciliation
|
||||
from . import test_search
|
||||
|
||||
@@ -46,3 +46,56 @@ class TestAccountJournal(AccountTestInvoicingCommon):
|
||||
|
||||
with self.assertRaises(UserError), self.cr.savepoint():
|
||||
self.company_data['default_journal_sale'].company_id = self.company_data_2['company']
|
||||
|
||||
def test_account_control_create_journal_entry(self):
|
||||
move_vals = {
|
||||
'line_ids': [
|
||||
(0, 0, {
|
||||
'name': 'debit',
|
||||
'account_id': self.company_data['default_account_revenue'].id,
|
||||
'debit': 100.0,
|
||||
'credit': 0.0,
|
||||
}),
|
||||
(0, 0, {
|
||||
'name': 'credit',
|
||||
'account_id': self.company_data['default_account_expense'].id,
|
||||
'debit': 0.0,
|
||||
'credit': 100.0,
|
||||
}),
|
||||
],
|
||||
}
|
||||
|
||||
# Should fail because 'default_account_expense' is not allowed.
|
||||
self.company_data['default_journal_misc'].account_control_ids |= self.company_data['default_account_revenue']
|
||||
with self.assertRaises(UserError), self.cr.savepoint():
|
||||
self.env['account.move'].create(move_vals)
|
||||
|
||||
# Should be allowed because both accounts are accepted.
|
||||
self.company_data['default_journal_misc'].account_control_ids |= self.company_data['default_account_expense']
|
||||
self.env['account.move'].create(move_vals)
|
||||
|
||||
def test_account_control_existing_journal_entry(self):
|
||||
self.env['account.move'].create({
|
||||
'line_ids': [
|
||||
(0, 0, {
|
||||
'name': 'debit',
|
||||
'account_id': self.company_data['default_account_revenue'].id,
|
||||
'debit': 100.0,
|
||||
'credit': 0.0,
|
||||
}),
|
||||
(0, 0, {
|
||||
'name': 'credit',
|
||||
'account_id': self.company_data['default_account_expense'].id,
|
||||
'debit': 0.0,
|
||||
'credit': 100.0,
|
||||
}),
|
||||
],
|
||||
})
|
||||
|
||||
# There is already an other line using the 'default_account_expense' account.
|
||||
with self.assertRaises(ValidationError), self.cr.savepoint():
|
||||
self.company_data['default_journal_misc'].account_control_ids |= self.company_data['default_account_revenue']
|
||||
|
||||
# Assigning both should be allowed
|
||||
self.company_data['default_journal_misc'].account_control_ids = \
|
||||
self.company_data['default_account_revenue'] + self.company_data['default_account_expense']
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
from odoo.addons.account.tests.common import AccountTestNoChartCommon
|
||||
from odoo.tests.common import tagged
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestControlJournalAccount(AccountTestNoChartCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestControlJournalAccount, cls).setUpClass()
|
||||
cls.setUpAdditionalAccounts()
|
||||
cls.setUpAccountJournal()
|
||||
|
||||
cls.move_data = {
|
||||
'journal_id': cls.journal_general.id,
|
||||
'line_ids': [
|
||||
(0, 0, {
|
||||
'account_id': cls.account_income.id,
|
||||
'debit': 100,
|
||||
}),
|
||||
(0, 0, {
|
||||
'account_id': cls.account_expense.id,
|
||||
'credit': 100,
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
def test_can_create(self):
|
||||
# There is no problem creating this move when there are no restrictions
|
||||
self.env['account.move'].create(self.move_data.copy())
|
||||
|
||||
def test_restrict_journal(self):
|
||||
self.journal_general.account_control_ids = self.account_income
|
||||
|
||||
# Cannot create because of restrictions on journal
|
||||
with self.assertRaises(UserError), self.cr.savepoint(flush=False):
|
||||
self.env['account.move'].create(self.move_data.copy())
|
||||
|
||||
self.journal_general.account_control_ids += self.account_expense
|
||||
|
||||
# Can create now
|
||||
self.env['account.move'].create(self.move_data.copy())
|
||||
|
||||
def test_prevent_restrict_journal(self):
|
||||
self.env['account.move'].create(self.move_data.copy())
|
||||
# There is already an item in another account
|
||||
with(self.assertRaises(ValidationError)):
|
||||
self.journal_general.account_control_ids = self.account_income
|
||||
# We can set the restriction to the account of the existing entry
|
||||
self.journal_general.account_control_ids = self.account_income + self.account_expense
|
||||
|
||||
def test_restrict_account(self):
|
||||
self.account_expense.allowed_journal_ids = self.journal_sale
|
||||
|
||||
# Cannot create because of restrictions on account
|
||||
with self.assertRaises(UserError), self.cr.savepoint(flush=False):
|
||||
move = self.env['account.move'].create(self.move_data.copy())
|
||||
|
||||
self.account_expense.allowed_journal_ids += self.journal_general
|
||||
|
||||
# Can create now
|
||||
self.env['account.move'].create(self.move_data.copy())
|
||||
|
||||
def test_prevent_restrict_account(self):
|
||||
self.env['account.move'].create(self.move_data.copy())
|
||||
# There is already an item in another journal
|
||||
with self.assertRaises(ValidationError):
|
||||
self.account_expense.allowed_journal_ids = self.journal_sale
|
||||
# We can set the restriction to the journal of the existing entry
|
||||
self.account_expense.allowed_journal_ids = self.journal_general
|
||||
Reference in New Issue
Block a user