Better tests
This commit is contained in:
parent
8f85126e64
commit
76a63f40ee
@ -25,24 +25,31 @@ class TestAccountInvoiceSpread(common.TransactionCase):
|
|||||||
type_receivable = self.env.ref('account.data_account_type_receivable')
|
type_receivable = self.env.ref('account.data_account_type_receivable')
|
||||||
type_payable = self.env.ref('account.data_account_type_payable')
|
type_payable = self.env.ref('account.data_account_type_payable')
|
||||||
|
|
||||||
def get_account(obj):
|
self.invoice_account = self.env['account.account'].create({
|
||||||
return self.env['account.account'].search([
|
'name': 'test_account_receivable',
|
||||||
('user_type_id', '=', obj.id),
|
'code': '123',
|
||||||
('reconcile', '=', True),
|
'user_type_id': type_receivable.id,
|
||||||
], limit=1)
|
'reconcile': True
|
||||||
|
})
|
||||||
|
|
||||||
self.invoice_account = get_account(type_receivable)
|
self.invoice_line_account = self.env['account.account'].create({
|
||||||
self.invoice_line_account = get_account(type_payable)
|
'name': 'test_account_payable',
|
||||||
|
'code': '321',
|
||||||
|
'user_type_id': type_payable.id,
|
||||||
|
'reconcile': True
|
||||||
|
})
|
||||||
|
|
||||||
self.spread_account = self.env['account.account'].search([
|
self.spread_account = self.env['account.account'].create({
|
||||||
('user_type_id', '=', type_payable.id),
|
'name': 'test spread account_payable',
|
||||||
('id', '!=', self.invoice_line_account.id)
|
'code': '765',
|
||||||
], limit=1)
|
'user_type_id': type_payable.id,
|
||||||
|
'reconcile': True
|
||||||
|
})
|
||||||
|
|
||||||
partner = self.env['res.partner'].create({
|
partner = self.env['res.partner'].create([{
|
||||||
'name': 'Partner Name',
|
'name': 'Partner Name',
|
||||||
'supplier': True,
|
'supplier': True,
|
||||||
})
|
}])
|
||||||
self.invoice = self.env['account.invoice'].create({
|
self.invoice = self.env['account.invoice'].create({
|
||||||
'partner_id': partner.id,
|
'partner_id': partner.id,
|
||||||
'account_id': self.invoice_account.id,
|
'account_id': self.invoice_account.id,
|
||||||
|
@ -24,19 +24,25 @@ class TestAccountSpreadCostRevenue(common.TransactionCase):
|
|||||||
super().setUp()
|
super().setUp()
|
||||||
self._load('account', 'test', 'account_minimal_test.xml')
|
self._load('account', 'test', 'account_minimal_test.xml')
|
||||||
|
|
||||||
def get_account(obj):
|
|
||||||
return self.env['account.account'].search([
|
|
||||||
('user_type_id', '=', obj.id)
|
|
||||||
], limit=1)
|
|
||||||
|
|
||||||
type_receivable = self.env.ref('account.data_account_type_receivable')
|
type_receivable = self.env.ref('account.data_account_type_receivable')
|
||||||
type_expenses = self.env.ref('account.data_account_type_expenses')
|
type_expenses = self.env.ref('account.data_account_type_expenses')
|
||||||
|
|
||||||
self.credit_account = get_account(type_receivable)
|
self.credit_account = self.env['account.account'].create({
|
||||||
self.debit_account = get_account(type_expenses)
|
'name': 'test_account_receivable',
|
||||||
|
'code': '123',
|
||||||
|
'user_type_id': type_receivable.id,
|
||||||
|
'reconcile': True
|
||||||
|
})
|
||||||
|
|
||||||
|
self.debit_account = self.env['account.account'].create({
|
||||||
|
'name': 'test account_expenses',
|
||||||
|
'code': '765',
|
||||||
|
'user_type_id': type_expenses.id,
|
||||||
|
'reconcile': True
|
||||||
|
})
|
||||||
|
|
||||||
def test_01_account_spread_defaults(self):
|
def test_01_account_spread_defaults(self):
|
||||||
|
this_year = datetime.date.today().year
|
||||||
spread = self.env['account.spread'].create({
|
spread = self.env['account.spread'].create({
|
||||||
'name': 'test',
|
'name': 'test',
|
||||||
'invoice_type': 'out_invoice',
|
'invoice_type': 'out_invoice',
|
||||||
@ -65,7 +71,7 @@ class TestAccountSpreadCostRevenue(common.TransactionCase):
|
|||||||
self.assertEqual(spread.unposted_amount, 0.)
|
self.assertEqual(spread.unposted_amount, 0.)
|
||||||
self.assertEqual(spread.total_amount, 0.)
|
self.assertEqual(spread.total_amount, 0.)
|
||||||
self.assertEqual(spread.estimated_amount, 0.)
|
self.assertEqual(spread.estimated_amount, 0.)
|
||||||
self.assertEqual(spread.spread_date, datetime.date(2018, 1, 1))
|
self.assertEqual(spread.spread_date, datetime.date(this_year, 1, 1))
|
||||||
self.assertTrue(spread.journal_id)
|
self.assertTrue(spread.journal_id)
|
||||||
self.assertEqual(spread.journal_id.type, 'general')
|
self.assertEqual(spread.journal_id.type, 'general')
|
||||||
|
|
||||||
|
@ -14,22 +14,30 @@ class TestComputeSpreadBoard(common.TransactionCase):
|
|||||||
type_receivable = self.env.ref('account.data_account_type_receivable')
|
type_receivable = self.env.ref('account.data_account_type_receivable')
|
||||||
type_expenses = self.env.ref('account.data_account_type_expenses')
|
type_expenses = self.env.ref('account.data_account_type_expenses')
|
||||||
|
|
||||||
def get_account(obj):
|
|
||||||
return self.env['account.account'].search([
|
|
||||||
('user_type_id', '=', obj.id)
|
|
||||||
], limit=1)
|
|
||||||
|
|
||||||
journal = self.env['account.journal'].search([
|
journal = self.env['account.journal'].search([
|
||||||
('type', '=', 'general')],
|
('type', '=', 'general')],
|
||||||
limit=1)
|
limit=1)
|
||||||
|
|
||||||
self.receivable_account = get_account(type_receivable)
|
self.receivable_account = self.env['account.account'].create({
|
||||||
self.expense_account = get_account(type_expenses)
|
'name': 'test_account_receivable',
|
||||||
|
'code': '123',
|
||||||
|
'user_type_id': type_receivable.id,
|
||||||
|
'reconcile': True
|
||||||
|
})
|
||||||
|
|
||||||
self.spread_account = self.env['account.account'].search([
|
self.expense_account = self.env['account.account'].create({
|
||||||
('user_type_id', '=', type_expenses.id),
|
'name': 'test account_expenses',
|
||||||
('id', '!=', self.expense_account.id)
|
'code': '765',
|
||||||
], limit=1)
|
'user_type_id': type_expenses.id,
|
||||||
|
'reconcile': True
|
||||||
|
})
|
||||||
|
|
||||||
|
self.spread_account = self.env['account.account'].create({
|
||||||
|
'name': 'test spread account_expenses',
|
||||||
|
'code': '321',
|
||||||
|
'user_type_id': type_expenses.id,
|
||||||
|
'reconcile': True
|
||||||
|
})
|
||||||
|
|
||||||
self.spread = self.env['account.spread'].create({
|
self.spread = self.env['account.spread'].create({
|
||||||
'name': 'test',
|
'name': 'test',
|
||||||
|
Loading…
Reference in New Issue
Block a user