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.

73 lines
2.7 KiB

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