You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.7 KiB

  1. # Copyright 2017 Tecnativa - Luis M. Ontalba
  2. # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0
  3. from odoo.tests import common
  4. from odoo import fields
  5. class TestAccountBankStatementImportMoveLine(common.SavepointCase):
  6. @classmethod
  7. def setUpClass(cls):
  8. super(TestAccountBankStatementImportMoveLine, cls).setUpClass()
  9. cls.account_type = cls.env['account.account.type'].create({
  10. 'name': 'Test Account Type'})
  11. cls.a_receivable = cls.env['account.account'].create({
  12. 'code': 'TAA',
  13. 'name': 'Test Receivable Account',
  14. 'internal_type': 'receivable',
  15. 'user_type_id': cls.account_type.id,
  16. })
  17. cls.partner = cls.env['res.partner'].create({
  18. 'name': 'Test Partner 2',
  19. 'parent_id': False,
  20. })
  21. cls.journal = cls.env['account.journal'].create({
  22. 'name': 'Test Journal',
  23. 'type': 'bank',
  24. })
  25. cls.invoice = cls.env['account.invoice'].create({
  26. 'name': 'Test Invoice 3',
  27. 'partner_id': cls.partner.id,
  28. 'type': 'out_invoice',
  29. 'journal_id': cls.journal.id,
  30. 'invoice_line_ids': [(0, 0, {
  31. 'account_id': cls.a_receivable.id,
  32. 'name': 'Test line',
  33. 'quantity': 1.0,
  34. 'price_unit': 100.00,
  35. })],
  36. })
  37. cls.statement = cls.env['account.bank.statement'].create({
  38. 'journal_id': cls.journal.id})
  39. def test_global(self):
  40. self.invoice.action_invoice_open()
  41. self.assertTrue(self.invoice.move_id)
  42. self.invoice.move_id.post()
  43. wizard_o = self.env['account.statement.line.create']
  44. context = wizard_o._context.copy()
  45. context.update({
  46. 'active_model': 'account.bank.statement',
  47. 'active_id': self.statement.id,
  48. })
  49. wizard = wizard_o.with_context(context).create({
  50. 'statement_id': self.statement.id,
  51. 'partner_id': self.partner.id,
  52. 'journal_ids': [(4, self.journal.id)],
  53. 'allow_blocked': True,
  54. 'date_type': 'move',
  55. 'move_date': fields.Date.today(),
  56. 'invoice': False,
  57. })
  58. wizard.populate()
  59. self.assertTrue(len(wizard.move_line_ids), 2)
  60. wizard.invoice = True
  61. wizard.move_line_filters_change()
  62. wizard.populate()
  63. self.assertTrue(len(wizard.move_line_ids), 1)
  64. line = wizard.move_line_ids[0]
  65. self.assertEqual(line.debit, self.invoice.amount_total)
  66. wizard.create_statement_lines()
  67. line = self.statement.line_ids[0]
  68. self.assertEqual(line.amount, self.invoice.amount_total)