banking-addons-team team mailing list archive
-
banking-addons-team team
-
Mailing list archive
-
Message #01895
[Merge] lp:~acsone-openerp/banking-addons/bank-statement-reconcile-70-bug-1313689-lmi into lp:banking-addons/bank-statement-reconcile-7.0
Laurent Mignon (Acsone) has proposed merging lp:~acsone-openerp/banking-addons/bank-statement-reconcile-70-bug-1313689-lmi into lp:banking-addons/bank-statement-reconcile-7.0.
Requested reviews:
Banking Addons Core Editors (banking-addons-team)
Related bugs:
Bug #1313689 in Banking Addons: "[7.0] account_statement_base_import: default account_id to false (mp:197755) breaks import of line without account_id"
https://bugs.launchpad.net/banking-addons/+bug/1313689
For more details, see:
https://code.launchpad.net/~acsone-openerp/banking-addons/bank-statement-reconcile-70-bug-1313689-lmi/+merge/217467
Remove the default value to False on account_id in account_statement_base_completion/statement.py since it breaks existing code.
I've the feeling that it's the responsibility of the parser to provide an blank/None account_id if the one provided by the base module 'account_statement_ext' does not apply to the expected behavior.
Regards,
lmi
--
https://code.launchpad.net/~acsone-openerp/banking-addons/bank-statement-reconcile-70-bug-1313689-lmi/+merge/217467
Your team Banking Addons Core Editors is requested to review the proposed merge of lp:~acsone-openerp/banking-addons/bank-statement-reconcile-70-bug-1313689-lmi into lp:banking-addons/bank-statement-reconcile-7.0.
=== modified file 'account_statement_base_import/data/statement.csv'
--- account_statement_base_import/data/statement.csv 2012-07-31 14:29:55 +0000
+++ account_statement_base_import/data/statement.csv 2014-04-28 15:17:18 +0000
@@ -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"
=== modified file 'account_statement_base_import/statement.py'
--- account_statement_base_import/statement.py 2014-04-15 09:52:48 +0000
+++ account_statement_base_import/statement.py 2014-04-28 15:17:18 +0000
@@ -109,7 +109,6 @@
:param int/long statement_id: ID of the concerned account.bank.statement
:return: dict of vals that will be passed to create method of statement line.
"""
- statement_obj = self.pool.get('account.bank.statement')
statement_line_obj = self.pool['account.bank.statement.line']
values = parser_vals
values['statement_id'] = statement_id
@@ -233,16 +232,11 @@
raise osv.except_osv(_("Statement import error"),
_("The statement cannot be created: %s") % st)
return statement_id
-
-
+
+
class AccountBankStatementLine(Model):
_inherit = "account.bank.statement.line"
- _columns = {
- 'account_id': fields.many2one('account.account','Account'),
- }
-
- _defaults = {
- 'account_id': False,
+ _columns = {
+ 'account_id': fields.many2one('account.account', 'Account'),
}
-
=== added directory 'account_statement_base_import/tests'
=== added file 'account_statement_base_import/tests/__init__.py'
--- account_statement_base_import/tests/__init__.py 1970-01-01 00:00:00 +0000
+++ account_statement_base_import/tests/__init__.py 2014-04-28 15:17:18 +0000
@@ -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 <http://www.gnu.org/licenses/>.
+#
+#
+
+from . import test_base_import
+
+checks = [
+ test_base_import
+]
=== added file 'account_statement_base_import/tests/test_base_import.py'
--- account_statement_base_import/tests/test_base_import.py 1970-01-01 00:00:00 +0000
+++ account_statement_base_import/tests/test_base_import.py 2014-04-28 15:17:18 +0000
@@ -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 <http://www.gnu.org/licenses/>.
+#
+#
+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")
Follow ups