Merge lp:~banking-addons-team/banking-addons/bank-statement-reconcile-fix-1082386 into lp:banking-addons/bank-statement-reconcile-61

Proposed by Alexandre Fayolle - camptocamp
Status: Merged
Merged at revision: 69
Proposed branch: lp:~banking-addons-team/banking-addons/bank-statement-reconcile-fix-1082386
Merge into: lp:banking-addons/bank-statement-reconcile-61
Diff against target: 30 lines (+5/-1)
1 file modified
account_statement_base_import/parser/file_parser.py (+5/-1)
To merge this branch: bzr merge lp:~banking-addons-team/banking-addons/bank-statement-reconcile-fix-1082386
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Approve
Review via email: mp+135905@code.launchpad.net

Description of the change

[FIX] account_statement_base_import: when importing from excel, use the date mode of the file, and not a hardcoded value

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Looks fine to me.
Thanks for the reference in the commit message :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_statement_base_import/parser/file_parser.py'
2--- account_statement_base_import/parser/file_parser.py 2012-09-26 12:51:06 +0000
3+++ account_statement_base_import/parser/file_parser.py 2012-11-23 14:09:26 +0000
4@@ -59,6 +59,9 @@
5 self.keys_to_validate = keys_to_validate
6 self.convertion_dict = convertion_dict
7 self.fieldnames = header
8+ self._datemode = 0 # used only for xls documents,
9+ # 0 means Windows mode (1900 based dates).
10+ # Set in _parse_xls, from the contents of the file
11
12 def _custom_format(self, *args, **kwargs):
13 """
14@@ -132,6 +135,7 @@
15 # We ensure that cursor is at beginig of file
16 wb_file.seek(0)
17 wb = xlrd.open_workbook(wb_file.name)
18+ self._datemode = wb.datemode
19 sheet = wb.sheet_by_index(0)
20 header = sheet.row_values(0)
21 res = []
22@@ -166,7 +170,7 @@
23 for line in result_set:
24 for rule in conversion_rules:
25 if conversion_rules[rule] == datetime.datetime:
26- t_tuple = xlrd.xldate_as_tuple(line[rule], 1)
27+ t_tuple = xlrd.xldate_as_tuple(line[rule], self._datemode)
28 line[rule] = datetime.datetime(*t_tuple)
29 else:
30 line[rule] = conversion_rules[rule](line[rule])

Subscribers

People subscribed via source and target branches