2
0
This commit is contained in:
Andrea 2019-05-06 15:16:10 +02:00 committed by Andrea Stirpe
parent 02eed5d78c
commit 5577ed7ec0
2 changed files with 80 additions and 0 deletions

View File

@ -259,6 +259,8 @@ class TestAccountInvoiceSpread(common.TransactionCase):
self.spread.invoice_id.action_cancel()
self.assertTrue(self.spread.invoice_line_id)
with self.assertRaises(UserError):
self.spread.unlink()
with self.assertRaises(UserError):
self.spread.action_unlink_invoice_line()
self.assertTrue(self.spread.invoice_line_id)
@ -352,6 +354,8 @@ class TestAccountInvoiceSpread(common.TransactionCase):
template = self.env['account.spread.template'].create({
'name': 'test',
'spread_type': 'purchase',
'period_number': 5,
'period_type': 'month',
'spread_account_id': spread_account.id,
'spread_journal_id': spread_journal_id,
})
@ -574,6 +578,7 @@ class TestAccountInvoiceSpread(common.TransactionCase):
count_balance_sheet += 1
self.assertEqual(count_balance_sheet, 1)
self.spread.company_id.force_move_auto_post = True
self.spread.line_ids.create_and_reconcile_moves()
spread_mls = self.spread.line_ids.mapped('move_id.line_ids')
@ -723,6 +728,9 @@ class TestAccountInvoiceSpread(common.TransactionCase):
with self.assertRaises(ValidationError):
self.spread2.journal_id = other_journal
with self.assertRaises(UserError):
self.spread2.unlink()
def test_14_create_all_moves(self):
self.spread.compute_spread_board()
spread_lines = self.spread.line_ids
@ -735,3 +743,6 @@ class TestAccountInvoiceSpread(common.TransactionCase):
spread_lines = self.spread.line_ids
for line in spread_lines:
self.assertTrue(line.move_id)
with self.assertRaises(ValidationError):
self.spread.unlink()

View File

@ -93,6 +93,10 @@ class TestAccountSpreadCostRevenue(common.TransactionCase):
self.assertTrue(spread.journal_id)
self.assertEqual(spread.journal_id.type, 'general')
self.assertFalse(spread.display_create_all_moves)
self.assertTrue(spread.display_recompute_buttons)
self.assertTrue(spread.display_move_line_auto_post)
def test_02_config_defaults(self):
my_company = self.env.user.company_id
self.assertFalse(my_company.default_spread_revenue_account_id)
@ -205,6 +209,10 @@ class TestAccountSpreadCostRevenue(common.TransactionCase):
self.assertFalse(invoice_line2.spread_id)
self.assertEqual(invoice_line2.spread_check, 'unavailable')
self.assertTrue(spread.display_create_all_moves)
self.assertTrue(spread.display_recompute_buttons)
self.assertTrue(spread.display_move_line_auto_post)
def test_07_create_spread_template(self):
account_revenue = self.account_revenue
account_payable = self.account_payable
@ -311,6 +319,10 @@ class TestAccountSpreadCostRevenue(common.TransactionCase):
spread.onchange_template()
self.assertEqual(spread.invoice_type, 'in_invoice')
self.assertFalse(spread.display_create_all_moves)
self.assertTrue(spread.display_recompute_buttons)
self.assertTrue(spread.display_move_line_auto_post)
def test_09_wrong_invoice_type(self):
invoice_account = self.account_receivable
invoice_line_account = self.account_expenses
@ -335,3 +347,60 @@ class TestAccountSpreadCostRevenue(common.TransactionCase):
})
with self.assertRaises(ValidationError):
invoice_line.spread_id = spread
def test_10_account_spread_unlink(self):
spread = self.env['account.spread'].create({
'name': 'test',
'invoice_type': 'out_invoice',
'debit_account_id': self.debit_account.id,
'credit_account_id': self.credit_account.id,
})
spread.unlink()
def test_11_compute_display_fields(self):
spread = self.env['account.spread'].create({
'name': 'test',
'invoice_type': 'out_invoice',
'debit_account_id': self.debit_account.id,
'credit_account_id': self.credit_account.id,
})
spread.company_id.allow_spread_planning = True
self.assertFalse(spread.display_create_all_moves)
self.assertTrue(spread.display_recompute_buttons)
self.assertTrue(spread.display_move_line_auto_post)
def test_12_compute_display_fields(self):
spread = self.env['account.spread'].create({
'name': 'test',
'invoice_type': 'out_invoice',
'debit_account_id': self.debit_account.id,
'credit_account_id': self.credit_account.id,
})
spread.company_id.allow_spread_planning = False
self.assertFalse(spread.display_create_all_moves)
self.assertTrue(spread.display_recompute_buttons)
self.assertTrue(spread.display_move_line_auto_post)
def test_13_compute_display_fields(self):
spread = self.env['account.spread'].create({
'name': 'test',
'invoice_type': 'out_invoice',
'debit_account_id': self.debit_account.id,
'credit_account_id': self.credit_account.id,
})
spread.company_id.force_move_auto_post = True
self.assertFalse(spread.display_create_all_moves)
self.assertTrue(spread.display_recompute_buttons)
self.assertFalse(spread.display_move_line_auto_post)
def test_14_compute_display_fields(self):
spread = self.env['account.spread'].create({
'name': 'test',
'invoice_type': 'out_invoice',
'debit_account_id': self.debit_account.id,
'credit_account_id': self.credit_account.id,
})
spread.company_id.force_move_auto_post = False
self.assertFalse(spread.display_create_all_moves)
self.assertTrue(spread.display_recompute_buttons)
self.assertTrue(spread.display_move_line_auto_post)