Merge lp:~camptocamp/openerp-swiss-localization/fix-v11-parser into lp:~camptocamp/openerp-swiss-localization/7.0

Proposed by Nicolas Bessi - Camptocamp
Status: Merged
Merged at revision: 174
Proposed branch: lp:~camptocamp/openerp-swiss-localization/fix-v11-parser
Merge into: lp:~camptocamp/openerp-swiss-localization/7.0
Diff against target: 37 lines (+6/-3)
1 file modified
l10n_ch_payment_slip/wizard/bvr_import.py (+6/-3)
To merge this branch: bzr merge lp:~camptocamp/openerp-swiss-localization/fix-v11-parser
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp code review, no test Approve
Review via email: mp+161102@code.launchpad.net

Description of the change

Fix of bug no: 1173149
+ v11 parser can support new line at end of file or empty line in body

To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

review: Approve (code review, no test)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_ch_payment_slip/wizard/bvr_import.py'
2--- l10n_ch_payment_slip/wizard/bvr_import.py 2013-02-15 13:28:41 +0000
3+++ l10n_ch_payment_slip/wizard/bvr_import.py 2013-04-26 11:50:40 +0000
4@@ -66,13 +66,15 @@
5 else:
6 return []
7
8- def _parse_lines(self, cursor, uid, lines, context=None):
9+ def _parse_lines(self, cursor, uid, inlines, context=None):
10 """Parses raw v11 line and populate records list with dict"""
11 records = []
12 total_amount = 0
13 total_cost = 0
14 find_total = False
15- for lines in lines:
16+ for lines in inlines:
17+ if not lines: # manage new line at end of file
18+ continue
19 (line, lines) = (lines[:128], lines[128:])
20 record = {}
21 if line[0:3] in ('999', '995'):
22@@ -114,7 +116,7 @@
23 total_amount += record['amount']
24 total_cost += record['cost']
25 records.append(record)
26- return records
27+ return records
28
29 def _create_voucher_from_record(self, cursor, uid, record,
30 statement, line_ids, context=None):
31@@ -203,6 +205,7 @@
32 statement_id = data['id']
33 lines = base64.decodestring(file).split("\n")
34 records = self._parse_lines(cursor, uid, lines, context=context)
35+
36 if context is None:
37 context = {}
38

Subscribers

People subscribed via source and target branches

to all changes: