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.

74 lines
3.0 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # This file is part of account_bank_statement_import,
  5. # an Odoo module.
  6. #
  7. # Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
  8. #
  9. # account_bank_statement_import is free software:
  10. # you can redistribute it and/or modify it under the terms of the GNU
  11. # Affero General Public License as published by the Free Software
  12. # Foundation,either version 3 of the License, or (at your option) any
  13. # later version.
  14. #
  15. # account_bank_statement_import is distributed
  16. # in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
  17. # even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  18. # PURPOSE. See the GNU Affero General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU Affero General Public License
  21. # along with account_bank_statement_import_coda.
  22. # If not, see <http://www.gnu.org/licenses/>.
  23. #
  24. ##############################################################################
  25. from openerp.tests.common import TransactionCase
  26. class TestAccountBankStatemetImport(TransactionCase):
  27. """Tests for import bank statement file import
  28. (account.bank.statement.import)
  29. """
  30. def setUp(self):
  31. super(TestAccountBankStatemetImport, self).setUp()
  32. self.statement_import_model = self.env[
  33. 'account.bank.statement.import']
  34. self.account_journal_model = self.env['account.journal']
  35. self.res_users_model = self.env['res.users']
  36. self.journal_id = self.ref('account.bank_journal')
  37. self.base_user_root_id = self.ref('base.user_root')
  38. self.base_user_root = self.res_users_model.browse(
  39. self.base_user_root_id)
  40. # create a new user that belongs to the same company as
  41. # user_root
  42. self.other_partner_id = self.env['res.partner'].create(
  43. {"name": "My other partner",
  44. "is_company": False,
  45. "email": "test@tes.ttest",
  46. })
  47. company_id = self.base_user_root.company_id.id
  48. self.other_user_id_a = self.res_users_model.create(
  49. {"partner_id": self.other_partner_id.id,
  50. "company_id": company_id,
  51. "company_ids": [(4, company_id)],
  52. "login": "my_login a",
  53. "name": "my user",
  54. "groups_id": [(4, self.ref('account.group_account_manager'))]
  55. })
  56. def test_create_bank_account(self):
  57. """Checks that the bank_account created by the import belongs to the
  58. partner linked to the company of the provided journal
  59. """
  60. journal = self.account_journal_model.browse(self.journal_id)
  61. expected_id = journal.company_id.partner_id.id
  62. st_import = self.statement_import_model.sudo(self.other_user_id_a.id)
  63. bank = st_import._create_bank_account(
  64. '001251882303', journal_id=self.journal_id)
  65. self.assertEqual(bank.partner_id.id,
  66. expected_id)