31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
|
from odoo.tests import tagged
|
|
from odoo.exceptions import UserError
|
|
|
|
|
|
@tagged('post_install', '-at_install')
|
|
class TestAccountJournal(AccountTestInvoicingCommon):
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super().setUpClass()
|
|
|
|
# Create another company.
|
|
cls.company_data_2 = cls.setup_company_data('company_2_data')
|
|
|
|
# By default, tests are run with the current user set on the first company.
|
|
cls.env.user.company_id = cls.company_data['company']
|
|
|
|
def test_changing_journal_company(self):
|
|
''' Ensure you can't change the company of an account.journal if there are some journal entries '''
|
|
|
|
self.env['account.move'].create({
|
|
'move_type': 'entry',
|
|
'date': '2019-01-01',
|
|
'journal_id': self.company_data['default_journal_sale'].id,
|
|
})
|
|
|
|
with self.assertRaises(UserError), self.cr.savepoint():
|
|
self.company_data['default_journal_sale'].company_id = self.company_data_2['company']
|