diff --git a/account_statement_base_import/data/statement.csv b/account_statement_base_import/data/statement.csv
index 31e2b398..fa059787 100644
--- a/account_statement_base_import/data/statement.csv
+++ b/account_statement_base_import/data/statement.csv
@@ -1,4 +1,4 @@
"ref";"date";"amount";"commission_amount";"label"
50969286;2011-03-07 13:45:14;118.4;-11.84;"label a"
-51065326;2011-03-05 13:45:14;189;-15.12;"label b"
+51065326;2011-03-02 13:45:14;189;-15.12;"label b"
51179306;2011-03-02 17:45:14;189;-15.12;"label c"
diff --git a/account_statement_base_import/statement.py b/account_statement_base_import/statement.py
index b12fffb7..20e4d700 100644
--- a/account_statement_base_import/statement.py
+++ b/account_statement_base_import/statement.py
@@ -240,7 +240,3 @@ class AccountBankStatementLine(Model):
_columns = {
'account_id': fields.many2one('account.account', 'Account'),
}
-
- _defaults = {
- 'account_id': False,
- }
diff --git a/account_statement_base_import/tests/__init__.py b/account_statement_base_import/tests/__init__.py
new file mode 100644
index 00000000..4bad4f26
--- /dev/null
+++ b/account_statement_base_import/tests/__init__.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+#
+#
+# Authors: Laurent Mignon
+# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
+# All Rights Reserved
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+
+from . import test_base_import
+
+checks = [
+ test_base_import
+]
diff --git a/account_statement_base_import/tests/test_base_import.py b/account_statement_base_import/tests/test_base_import.py
new file mode 100644
index 00000000..f48aea66
--- /dev/null
+++ b/account_statement_base_import/tests/test_base_import.py
@@ -0,0 +1,105 @@
+# -*- coding: utf-8 -*-
+#
+#
+# Authors: Laurent Mignon
+# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
+# All Rights Reserved
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+import base64
+import inspect
+import os
+
+from openerp.tests import common
+
+
+class test_coda_import(common.TransactionCase):
+
+ def prepare(self):
+ self.company_a = self.browse_ref('base.main_company')
+ self.profile_obj = self.registry("account.statement.profile")
+ self.account_bank_statement_obj = self.registry("account.bank.statement")
+ # create the 2009 fiscal year since imported coda file reference statement lines in 2009
+ self.fiscalyear_id = self._create_fiscalyear("2011", self.company_a.id)
+
+ self.account_id = self.ref("account.a_recv")
+ self.journal_id = self.ref("account.bank_journal")
+ self.import_wizard_obj = self.registry('credit.statement.import')
+ self.profile_id = self.profile_obj.create(self.cr, self.uid, {
+ "name": "BASE_PROFILE",
+ "commission_account_id": self.account_id,
+ "journal_id": self.journal_id,
+ "import_type": "generic_csvxls_so"})
+
+ def _create_fiscalyear(self, year, company_id):
+ fiscalyear_obj = self.registry("account.fiscalyear")
+ fiscalyear_id = fiscalyear_obj.create(self.cr, self.uid, {
+ "name": year,
+ "code": year,
+ "date_start": year + "-01-01",
+ "date_stop": year + "-12-31",
+ "company_id": company_id
+ })
+ fiscalyear_obj.create_period3(self.cr, self.uid, [fiscalyear_id])
+ return fiscalyear_id
+
+ def _filename_to_abs_filename(self, file_name):
+ dir_name = os.path.dirname(inspect.getfile(self.__class__))
+ return os.path.join(dir_name, file_name)
+
+ def _import_file(self, file_name):
+ """ import a file using the wizard
+ return the create account.bank.statement object
+ """
+ with open(file_name) as f:
+ content = f.read()
+ wizard_id = self.import_wizard_obj.create(self.cr, self.uid, {
+ "profile_id": self.profile_id,
+ 'input_statement': base64.b64encode(content),
+ 'file_name': os.path.basename(file_name),
+ })
+ res = self.import_wizard_obj.import_statement(self.cr, self.uid, wizard_id)
+ statement_id = self.account_bank_statement_obj.search(self.cr, self.uid, eval(res['domain']))
+ return self.account_bank_statement_obj.browse(self.cr, self.uid, statement_id)[0]
+
+ def test_simple_xls(self):
+ """Test import from xls
+ """
+ self.prepare()
+ file_name = self._filename_to_abs_filename(os.path.join("..", "data", "statement.xls"))
+ statement = self._import_file(file_name)
+ self._validate_imported_satement(statement)
+
+ def test_simple_csv(self):
+ """Test import from csv
+ """
+ self.prepare()
+ file_name = self._filename_to_abs_filename(os.path.join("..", "data", "statement.csv"))
+ statement = self._import_file(file_name)
+ self._validate_imported_satement(statement)
+
+ def _validate_imported_satement(self, statement):
+ self.assertEqual("/", statement.name)
+ self.assertEqual(0.0, statement.balance_start)
+ self.assertEqual(0.0, statement.balance_end_real)
+ self.assertEqual(3, len(statement.line_ids))
+ self.assertTrue(statement.account_id)
+ st_line_obj = statement.line_ids[1]
+ # common infos
+ self.assertEqual(st_line_obj.ref, "51065326")
+ self.assertEqual(st_line_obj.date, "2011-03-02")
+ self.assertEqual(st_line_obj.amount, 189.0)
+ self.assertEqual(st_line_obj.name, "label b")