Merge lp:~camptocamp/account-financial-report/7.0-add-reference-field-xls-mdh into lp:~account-report-core-editor/account-financial-report/7.0

Proposed by Matthieu Dietrich @ camptocamp
Status: Approved
Approved by: Frederic Clementi - Camptocamp
Approved revision: 87
Proposed branch: lp:~camptocamp/account-financial-report/7.0-add-reference-field-xls-mdh
Merge into: lp:~account-report-core-editor/account-financial-report/7.0
Diff against target: 1456 lines (+386/-358)
3 files modified
account_financial_report_webkit_xls/report/general_ledger_xls.py (+70/-48)
account_financial_report_webkit_xls/report/open_invoices_xls.py (+232/-229)
account_financial_report_webkit_xls/report/partner_ledger_xls.py (+84/-81)
To merge this branch: bzr merge lp:~camptocamp/account-financial-report/7.0-add-reference-field-xls-mdh
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza Needs Resubmitting
Alexandre Fayolle - camptocamp code review, no test Needs Fixing
Frederic Clementi - Camptocamp functional Approve
Review via email: mp+214905@code.launchpad.net

Commit message

[IMP] add move line reference field to XLS reports (open invoices, general ledger, partner ledgers)

Description of the change

Related to lp:~camptocamp/account-financial-report/7.0-add-reference-field-mdh, this adds the reference fiels to XLS reports.

To post a comment you must log in.
87. By Matthieu Dietrich @ camptocamp on 2014-04-11

[FIX] realign header

Revision history for this message
Frederic Clementi - Camptocamp (frederic-clementi) wrote :

LGTM

review: Approve (functional)
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

please add an automated test which exercises the new code, so that we can at least easily check that it does not crash.

review: Needs Fixing (code review, no test)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :
review: Needs Resubmitting

Unmerged revisions

87. By Matthieu Dietrich @ camptocamp on 2014-04-11

[FIX] realign header

86. By Matthieu Dietrich @ camptocamp on 2014-04-09

[IMP] added reference field to XLS reports

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_financial_report_webkit_xls/report/general_ledger_xls.py'
2--- account_financial_report_webkit_xls/report/general_ledger_xls.py 2013-10-31 18:01:41 +0000
3+++ account_financial_report_webkit_xls/report/general_ledger_xls.py 2014-04-11 09:05:21 +0000
4@@ -38,32 +38,33 @@
5 ('journal', 12),
6 ('account_code', 12),
7 ('partner', 30),
8+ ('ref', 20),
9 ('label', 45),
10 ('counterpart', 30),
11- ('debit', 15),
12+ ('debit', 15),
13 ('credit', 15),
14 ('cumul_bal', 15),
15- ('curr_bal', 15),
16+ ('curr_bal', 15),
17 ('curr_code', 7),
18 ]
19
20 class general_ledger_xls(report_xls):
21 column_sizes = [x[1] for x in _column_sizes]
22-
23+
24 def generate_xls_report(self, _p, _xs, data, objects, wb):
25-
26+
27 ws = wb.add_sheet(_p.report_name[:31])
28 ws.panes_frozen = True
29 ws.remove_splits = True
30 ws.portrait = 0 # Landscape
31 ws.fit_width_to_pages = 1
32 row_pos = 0
33-
34+
35 # set print header/footer
36 ws.header_str = self.xls_headers['standard']
37 ws.footer_str = self.xls_footers['standard']
38-
39- # cf. account_report_general_ledger.mako
40+
41+ # cf. account_report_general_ledger.mako
42 initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')}
43
44 # Title
45@@ -71,7 +72,7 @@
46 report_name = ' - '.join([_p.report_name.upper(), _p.company.partner_id.name, _p.company.currency_id.name])
47 c_specs = [
48 ('report_name', 1, 0, 'text', report_name),
49- ]
50+ ]
51 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
52 row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style)
53
54@@ -79,21 +80,30 @@
55 c_sizes = self.column_sizes
56 c_specs = [('empty%s'%i, 1, c_sizes[i], 'text', None) for i in range(0,len(c_sizes))]
57 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
58- row_pos = self.xls_write_row(ws, row_pos, row_data, set_column_size=True)
59-
60+ row_pos = self.xls_write_row(ws, row_pos, row_data, set_column_size=True)
61+
62 # Header Table
63 cell_format = _xs['bold'] + _xs['fill_blue'] + _xs['borders_all']
64 cell_style = xlwt.easyxf(cell_format)
65 cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
66 c_specs = [
67 ('coa', 2, 0, 'text', _('Chart of Account')),
68- ('fy', 1, 0, 'text', _('Fiscal Year')),
69+ ('fy', 2, 0, 'text', _('Fiscal Year')),
70 ('df', 3, 0, 'text', _p.filter_form(data) == 'filter_date' and _('Dates Filter') or _('Periods Filter')),
71- ('af', 1, 0, 'text', _('Accounts Filter')),
72+ ('af', 1, 0, 'text', _('Accounts Filter'))
73+ ]
74+
75+ if _p.amount_currency(data):
76+ c_specs += [
77+ ('tm', 3, 0, 'text', _('Target Moves')),
78+ ('ib', 3, 0, 'text', _('Initial Balance')),
79+ ]
80+ else:
81+ c_specs += [
82 ('tm', 2, 0, 'text', _('Target Moves')),
83 ('ib', 2, 0, 'text', _('Initial Balance')),
84+ ]
85
86- ]
87 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
88 row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style_center)
89
90@@ -102,11 +112,11 @@
91 cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
92 c_specs = [
93 ('coa', 2, 0, 'text', _p.chart_account.name),
94- ('fy', 1, 0, 'text', _p.fiscalyear.name if _p.fiscalyear else '-'),
95+ ('fy', 2, 0, 'text', _p.fiscalyear.name if _p.fiscalyear else '-'),
96 ]
97 df = _('From') + ': '
98 if _p.filter_form(data) == 'filter_date':
99- df += _p.start_date if _p.start_date else u''
100+ df += _p.start_date if _p.start_date else u''
101 else:
102 df += _p.start_period.name if _p.start_period else u''
103 df += ' ' + _('To') + ': '
104@@ -117,12 +127,22 @@
105 c_specs += [
106 ('df', 3, 0, 'text', df),
107 ('af', 1, 0, 'text', _p.accounts(data) and ', '.join([account.code for account in _p.accounts(data)]) or _('All')),
108+ ]
109+
110+ if _p.amount_currency(data):
111+ c_specs += [
112+ ('tm', 3, 0, 'text', _p.display_target_move(data)),
113+ ('ib', 3, 0, 'text', initial_balance_text[_p.initial_balance_mode]),
114+ ]
115+ else:
116+ c_specs += [
117 ('tm', 2, 0, 'text', _p.display_target_move(data)),
118 ('ib', 2, 0, 'text', initial_balance_text[_p.initial_balance_mode]),
119- ]
120+ ]
121+
122 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
123- row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style_center)
124- ws.set_horz_split_pos(row_pos)
125+ row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style_center)
126+ ws.set_horz_split_pos(row_pos)
127 row_pos += 1
128
129 # Column Title Row
130@@ -150,19 +170,20 @@
131 ('journal', 1, 0, 'text', _('Journal'), None, c_hdr_cell_style),
132 ('account_code', 1, 0, 'text', _('Account'), None, c_hdr_cell_style),
133 ('partner', 1, 0, 'text', _('Partner'), None, c_hdr_cell_style),
134+ ('ref', 1, 0, 'text', _('Reference'), None, c_hdr_cell_style),
135 ('label', 1, 0, 'text', _('Label'), None, c_hdr_cell_style),
136 ('counterpart', 1, 0, 'text', _('Counterpart'), None, c_hdr_cell_style),
137 ('debit', 1, 0, 'text', _('Debit'), None, c_hdr_cell_style_right),
138 ('credit', 1, 0, 'text', _('Credit'), None, c_hdr_cell_style_right),
139- ('cumul_bal', 1, 0, 'text', _('Cumul. Bal.'), None, c_hdr_cell_style_right),
140- ]
141+ ('cumul_bal', 1, 0, 'text', _('Cumul. Bal.'), None, c_hdr_cell_style_right),
142+ ]
143 if _p.amount_currency(data):
144 c_specs += [
145 ('curr_bal', 1, 0, 'text', _('Curr. Bal.'), None, c_hdr_cell_style_right),
146 ('curr_code', 1, 0, 'text', _('Curr.'), None, c_hdr_cell_style_center),
147 ]
148 c_hdr_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
149-
150+
151 # cell styles for ledger lines
152 ll_cell_format = _xs['borders_all']
153 ll_cell_style = xlwt.easyxf(ll_cell_format)
154@@ -170,7 +191,7 @@
155 ll_cell_style_center = xlwt.easyxf(ll_cell_format + _xs['center'])
156 ll_cell_style_date = xlwt.easyxf(ll_cell_format + _xs['left'], num_format_str = report_xls.date_format)
157 ll_cell_style_decimal = xlwt.easyxf(ll_cell_format + _xs['right'], num_format_str = report_xls.decimal_format)
158-
159+
160 cnt = 0
161 for account in objects:
162
163@@ -188,36 +209,36 @@
164 ('acc_title', 11, 0, 'text', ' - '.join([account.code, account.name])),
165 ]
166 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
167- row_pos = self.xls_write_row(ws, row_pos, row_data, c_title_cell_style)
168- row_pos = self.xls_write_row(ws, row_pos, c_hdr_data)
169+ row_pos = self.xls_write_row(ws, row_pos, row_data, c_title_cell_style)
170+ row_pos = self.xls_write_row(ws, row_pos, c_hdr_data)
171 row_start = row_pos
172
173 if display_initial_balance:
174 cumul_debit = account.init_balance.get('debit') or 0.0
175 cumul_credit = account.init_balance.get('credit') or 0.0
176 cumul_balance = account.init_balance.get('init_balance') or 0.0
177- cumul_balance_curr = account.init_balance.get('init_balance_currency') or 0.0
178- debit_cell = rowcol_to_cell(row_pos, 8)
179- credit_cell = rowcol_to_cell(row_pos, 9)
180- bal_formula = debit_cell + '-' + credit_cell
181- c_specs = [('empty%s' %x, 1, 0, 'text', None) for x in range(6)]
182+ cumul_balance_curr = account.init_balance.get('init_balance_currency') or 0.0
183+ debit_cell = rowcol_to_cell(row_pos, 9)
184+ credit_cell = rowcol_to_cell(row_pos, 10)
185+ bal_formula = debit_cell + '-' + credit_cell
186+ c_specs = [('empty%s' %x, 1, 0, 'text', None) for x in range(7)]
187 c_specs += [
188 ('init_bal', 1, 0, 'text', _('Initial Balance')),
189 ('counterpart', 1, 0, 'text', None),
190 ('debit', 1, 0, 'number', cumul_debit, None, c_init_cell_style_decimal),
191 ('credit', 1, 0, 'number', cumul_credit, None, c_init_cell_style_decimal),
192- ('cumul_bal', 1, 0, 'number', cumul_balance, None, c_init_cell_style_decimal),
193- ]
194+ ('cumul_bal', 1, 0, 'number', cumul_balance, None, c_init_cell_style_decimal),
195+ ]
196 if _p.amount_currency(data):
197 c_specs += [
198 ('curr_bal', 1, 0, 'number', cumul_balance_curr, None, c_init_cell_style_decimal),
199 ('curr_code', 1, 0, 'text', None),
200 ]
201 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
202- row_pos = self.xls_write_row(ws, row_pos, row_data, c_init_cell_style)
203+ row_pos = self.xls_write_row(ws, row_pos, row_data, c_init_cell_style)
204
205 for line in account.ledger_lines:
206-
207+
208 cumul_debit += line.get('debit') or 0.0
209 cumul_credit += line.get('credit') or 0.0
210 cumul_balance_curr += line.get('amount_currency') or 0.0
211@@ -234,42 +255,43 @@
212 else:
213 c_specs = [
214 ('ldate', 1, 0, 'text', None),
215- ]
216+ ]
217 c_specs += [
218 ('period', 1, 0, 'text', line.get('period_code') or ''),
219 ('move', 1, 0, 'text', line.get('move_name') or ''),
220 ('journal', 1, 0, 'text', line.get('jcode') or ''),
221 ('account_code', 1, 0, 'text', account.code),
222 ('partner', 1, 0, 'text', line.get('partner_name') or ''),
223+ ('ref', 1, 0, 'text', line.get('lref') or ''),
224 ('label', 1, 0, 'text', label),
225 ('counterpart', 1, 0, 'text', line.get('counterparts') or ''),
226 ('debit', 1, 0, 'number', line.get('debit', 0.0), None, ll_cell_style_decimal),
227 ('credit', 1, 0, 'number', line.get('credit', 0.0), None, ll_cell_style_decimal),
228 ('cumul_bal', 1, 0, 'number', cumul_balance, None, ll_cell_style_decimal),
229- ]
230+ ]
231 if _p.amount_currency(data):
232 c_specs += [
233 ('curr_bal', 1, 0, 'number', line.get('amount_currency') or 0.0, None, ll_cell_style_decimal),
234 ('curr_code', 1, 0, 'text', line.get('currency_code') or '', None, ll_cell_style_center),
235 ]
236 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
237- row_pos = self.xls_write_row(ws, row_pos, row_data, ll_cell_style)
238-
239- debit_start = rowcol_to_cell(row_start, 8)
240- debit_end = rowcol_to_cell(row_pos-1, 8)
241+ row_pos = self.xls_write_row(ws, row_pos, row_data, ll_cell_style)
242+
243+ debit_start = rowcol_to_cell(row_start, 9)
244+ debit_end = rowcol_to_cell(row_pos-1, 9)
245 debit_formula = 'SUM(' + debit_start + ':' + debit_end + ')'
246- credit_start = rowcol_to_cell(row_start, 9)
247- credit_end = rowcol_to_cell(row_pos-1, 9)
248+ credit_start = rowcol_to_cell(row_start, 10)
249+ credit_end = rowcol_to_cell(row_pos-1, 10)
250 credit_formula = 'SUM(' + credit_start + ':' + credit_end + ')'
251- balance_debit = rowcol_to_cell(row_pos, 8)
252- balance_credit = rowcol_to_cell(row_pos, 9)
253+ balance_debit = rowcol_to_cell(row_pos, 9)
254+ balance_credit = rowcol_to_cell(row_pos, 10)
255 balance_formula = balance_debit + '-' + balance_credit
256 c_specs = [
257- ('acc_title', 7, 0, 'text', ' - '.join([account.code, account.name])),
258+ ('acc_title', 8, 0, 'text', ' - '.join([account.code, account.name])),
259 ('cum_bal', 1, 0, 'text', _('Cumulated Balance on Account'), None, c_hdr_cell_style_right),
260- ('debit', 1, 0, 'number', None, debit_formula, c_hdr_cell_style_decimal),
261- ('credit', 1, 0, 'number', None, credit_formula, c_hdr_cell_style_decimal),
262- ('balance', 1, 0, 'number', None, balance_formula, c_hdr_cell_style_decimal),
263+ ('debit', 1, 0, 'number', None, debit_formula, c_hdr_cell_style_decimal),
264+ ('credit', 1, 0, 'number', None, credit_formula, c_hdr_cell_style_decimal),
265+ ('balance', 1, 0, 'number', None, balance_formula, c_hdr_cell_style_decimal),
266 ]
267 if _p.amount_currency(data):
268 if account.currency_id:
269@@ -278,7 +300,7 @@
270 c_specs += [('curr_bal', 1, 0, 'text', None)]
271 c_specs += [('curr_code', 1, 0, 'text', None)]
272 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
273- row_pos = self.xls_write_row(ws, row_pos, row_data, c_hdr_cell_style)
274+ row_pos = self.xls_write_row(ws, row_pos, row_data, c_hdr_cell_style)
275 row_pos += 1
276
277 general_ledger_xls('report.account.account_report_general_ledger_xls', 'account.account',
278
279=== modified file 'account_financial_report_webkit_xls/report/open_invoices_xls.py'
280--- account_financial_report_webkit_xls/report/open_invoices_xls.py 2013-10-31 18:01:41 +0000
281+++ account_financial_report_webkit_xls/report/open_invoices_xls.py 2014-04-11 09:05:21 +0000
282@@ -32,60 +32,60 @@
283 #_logger = logging.getLogger(__name__)
284
285 class open_invoices_xls(report_xls):
286- column_sizes = [12,12,20,15,30,30,14,14,14,14,14,14,10]
287-
288+ column_sizes = [12,12,20,15,30,20,30,14,14,14,14,14,14,10]
289+
290 def global_initializations(self, wb, _p, xlwt, _xs, objects, data):
291 # this procedure will initialise variables and Excel cell styles and return them as global ones
292- global ws
293+ global ws
294 ws = wb.add_sheet(_p.report_name[:31])
295 ws.panes_frozen = True
296 ws.remove_splits = True
297 ws.portrait = 0 # Landscape
298 ws.fit_width_to_pages = 1
299 ws.header_str = self.xls_headers['standard']
300- ws.footer_str = self.xls_footers['standard']
301- #-------------------------------------------------------
302- global nbr_columns #number of columns is 11 in case of normal report, 13 in case the option currency is selected and 12 in case of the regroup by currency option is checked
303+ ws.footer_str = self.xls_footers['standard']
304+ #-------------------------------------------------------
305+ global nbr_columns #number of columns is 11 in case of normal report, 13 in case the option currency is selected and 12 in case of the regroup by currency option is checked
306 group_lines = False
307 for acc in objects: #search if the regroup option is selected by browsing the accounts defined in objects - see account_report_open_invoices.mako
308 if hasattr(acc, 'grouped_ledger_lines'):
309 group_lines = True
310 if group_lines:
311+ nbr_columns = 13
312+ elif _p.amount_currency(data) and not group_lines:
313+ nbr_columns = 14
314+ else:
315 nbr_columns = 12
316- elif _p.amount_currency(data) and not group_lines:
317- nbr_columns = 13
318- else:
319- nbr_columns = 11
320- #-------------------------------------------------------
321+ #-------------------------------------------------------
322 global style_font12 #cell style for report title
323- style_font12 = xlwt.easyxf(_xs['xls_title'])
324+ style_font12 = xlwt.easyxf(_xs['xls_title'])
325 #-------------------------------------------------------
326 global style_default
327- style_default = xlwt.easyxf(_xs['borders_all'])
328+ style_default = xlwt.easyxf(_xs['borders_all'])
329 #-------------------------------------------------------
330 global style_default_italic
331- style_default_italic = xlwt.easyxf(_xs['borders_all'] + _xs['italic'])
332+ style_default_italic = xlwt.easyxf(_xs['borders_all'] + _xs['italic'])
333 #-------------------------------------------------------
334 global style_bold
335- style_bold = xlwt.easyxf(_xs['bold'] + _xs['borders_all'])
336+ style_bold = xlwt.easyxf(_xs['bold'] + _xs['borders_all'])
337 #-------------------------------------------------------
338 global style_bold_center
339- style_bold_center = xlwt.easyxf(_xs['bold'] + _xs['borders_all'] + _xs['center'])
340- #-------------------------------------------------------
341+ style_bold_center = xlwt.easyxf(_xs['bold'] + _xs['borders_all'] + _xs['center'])
342+ #-------------------------------------------------------
343 global style_bold_italic
344 style_bold_italic = xlwt.easyxf(_xs['bold'] + _xs['borders_all'] + _xs['italic'])
345- #-------------------------------------------------------
346+ #-------------------------------------------------------
347 global style_bold_italic_decimal
348 style_bold_italic_decimal = xlwt.easyxf(_xs['bold'] + _xs['borders_all'] + _xs['italic'] + _xs['right'], num_format_str = report_xls.decimal_format)
349 #-------------------------------------------------------
350 global style_bold_blue
351- style_bold_blue = xlwt.easyxf(_xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] )
352+ style_bold_blue = xlwt.easyxf(_xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] )
353 #-------------------------------------------------------
354 global style_bold_blue_italic_decimal
355- style_bold_blue_italic_decimal = xlwt.easyxf(_xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + _xs['italic'], num_format_str = report_xls.decimal_format)
356+ style_bold_blue_italic_decimal = xlwt.easyxf(_xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + _xs['italic'], num_format_str = report_xls.decimal_format)
357 #-------------------------------------------------------
358 global style_bold_blue_center #cell style for header titles: 'Chart of accounts' - 'Fiscal year' ...
359- style_bold_blue_center= xlwt.easyxf(_xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + _xs['center'])
360+ style_bold_blue_center= xlwt.easyxf(_xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + _xs['center'])
361 #-------------------------------------------------------
362 global style_center #cell style for header data: 'Chart of accounts' - 'Fiscal year' ...
363 style_center = xlwt.easyxf(_xs['borders_all'] + _xs['wrap'] + _xs['center'])
364@@ -94,7 +94,7 @@
365 style_yellow_bold = xlwt.easyxf(_xs['bold'] + _xs['fill'] + _xs['borders_all'])
366 #-------------------------------------------------------
367 global style_yellow_bold_right #cell style for columns titles 'Date'- 'Period' - 'Entry'...
368- style_yellow_bold_right = xlwt.easyxf(_xs['bold'] + _xs['fill'] + _xs['borders_all'] + _xs['right'])
369+ style_yellow_bold_right = xlwt.easyxf(_xs['bold'] + _xs['fill'] + _xs['borders_all'] + _xs['right'])
370 #-------------------------------------------------------
371 global style_right
372 style_right = xlwt.easyxf(_xs['borders_all'] + _xs['right'])
373@@ -117,7 +117,7 @@
374 global style_account_title, style_account_title_right, style_account_title_decimal
375 cell_format = _xs['xls_title'] + _xs['bold'] + _xs['fill'] + _xs['borders_all']
376 style_account_title = xlwt.easyxf(cell_format)
377- style_account_title_right = xlwt.easyxf(cell_format + _xs['right'])
378+ style_account_title_right = xlwt.easyxf(cell_format + _xs['right'])
379 style_account_title_decimal = xlwt.easyxf(cell_format + _xs['right'], num_format_str = report_xls.decimal_format)
380 #-------------------------------------------------------
381 global style_partner_row
382@@ -130,42 +130,42 @@
383 style_partner_cumul_right = xlwt.easyxf(cell_format + _xs['right'])
384 style_partner_cumul_center = xlwt.easyxf(cell_format + _xs['center'])
385 style_partner_cumul_decimal = xlwt.easyxf(cell_format + _xs['right'], num_format_str = report_xls.decimal_format)
386-
387+
388 def print_title(self, _p, row_position): # print the first line "OPEN INVOICE REPORT - db name - Currency
389 report_name = ' - '.join([_p.report_name.upper(), _p.company.partner_id.name, _p.company.currency_id.name])
390- c_specs = [('report_name', nbr_columns, 0, 'text', report_name), ]
391+ c_specs = [('report_name', nbr_columns, 0, 'text', report_name), ]
392 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
393 row_position = self.xls_write_row(ws, row_position, row_data, row_style=style_font12)
394 return row_position
395-
396+
397 def print_empty_row(self, row_position): #send an empty row to the Excel document
398 c_sizes = self.column_sizes
399 c_specs = [('empty%s'%i, 1, c_sizes[i], 'text', None) for i in range(0,len(c_sizes))]
400 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
401- row_position = self.xls_write_row(ws, row_position, row_data, set_column_size=True)
402- return row_position
403-
404- def print_header_titles(self, _p, data, row_position): #Fill in the titles of the header summary tables: Chart of account - Fiscal year - ...
405+ row_position = self.xls_write_row(ws, row_position, row_data, set_column_size=True)
406+ return row_position
407+
408+ def print_header_titles(self, _p, data, row_position): #Fill in the titles of the header summary tables: Chart of account - Fiscal year - ...
409 c_specs = [
410- ('coa', 2, 0, 'text', _('Chart of Account'), None, style_bold_blue_center),
411+ ('coa', 3, 0, 'text', _('Chart of Account'), None, style_bold_blue_center),
412 ('fy', 2, 0, 'text', _('Fiscal Year'), None, style_bold_blue_center),
413 ('df', 2, 0, 'text', _p.filter_form(data) == 'filter_date' and _('Dates Filter') or _('Periods Filter'), None, style_bold_blue_center),
414- ('cd', 1 if nbr_columns == 11 else 2 , 0, 'text', _('Clearance Date'), None, style_bold_blue_center),
415+ ('cd', 1 if nbr_columns == 12 else 2 , 0, 'text', _('Clearance Date'), None, style_bold_blue_center),
416 ('af', 2, 0, 'text', _('Accounts Filter'), None, style_bold_blue_center),
417- ('tm', 3 if nbr_columns == 13 else 2, 0, 'text', _('Target Moves'), None, style_bold_blue_center),
418- ]
419+ ('tm', 3 if nbr_columns == 14 else 2, 0, 'text', _('Target Moves'), None, style_bold_blue_center),
420+ ]
421 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
422 row_position = self.xls_write_row(ws, row_position, row_data, row_style=style_bold_blue_center)
423 return row_position
424-
425- def print_header_data(self, _p, data, row_position): #Fill in the data of the header summary tables: Chart of account - Fiscal year - ...
426+
427+ def print_header_data(self, _p, data, row_position): #Fill in the data of the header summary tables: Chart of account - Fiscal year - ...
428 c_specs = [
429- ('coa', 2, 0, 'text', _p.chart_account.name, None, style_center),
430+ ('coa', 3, 0, 'text', _p.chart_account.name, None, style_center),
431 ('fy', 2, 0, 'text', _p.fiscalyear.name if _p.fiscalyear else '-', None, style_center),
432 ]
433 df = _('From') + ': '
434 if _p.filter_form(data) == 'filter_date':
435- df += _p.start_date if _p.start_date else u''
436+ df += _p.start_date if _p.start_date else u''
437 else:
438 df += _p.start_period.name if _p.start_period else u''
439 df += ' ' + _('To') + ': '
440@@ -175,15 +175,15 @@
441 df += _p.stop_period.name if _p.stop_period else u''
442 c_specs += [
443 ('df', 2, 0, 'text', df, None, style_center),
444- ('cd', 1 if nbr_columns == 11 else 2, 0, 'text', _p.date_until, None, style_center), #clearance date
445- ('af', 2, 0, 'text', _('Custom Filter') if _p.partner_ids else _p.display_partner_account(data), None, style_center),
446- ('tm', 3 if nbr_columns == 13 else 2, 0, 'text', _p.display_target_move(data), None, style_center),
447- ]
448+ ('cd', 1 if nbr_columns == 12 else 2, 0, 'text', _p.date_until, None, style_center), #clearance date
449+ ('af', 2, 0, 'text', _('Custom Filter') if _p.partner_ids else _p.display_partner_account(data), None, style_center),
450+ ('tm', 3 if nbr_columns == 14 else 2, 0, 'text', _p.display_target_move(data), None, style_center),
451+ ]
452 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
453 row_position = self.xls_write_row(ws, row_position, row_data, row_style=style_center)
454 return row_position
455-
456- def print_columns_title(self, _p, row_position, data, group_lines=False): # Fill in a row with the titles of the columns for the invoice lines: Date - Period - Entry -...
457+
458+ def print_columns_title(self, _p, row_position, data, group_lines=False): # Fill in a row with the titles of the columns for the invoice lines: Date - Period - Entry -...
459 c_specs = [
460 ('date', 1, 0, 'text', _('Date'),None,style_yellow_bold),
461 ('period', 1, 0, 'text', _('Period'),None,style_yellow_bold),
462@@ -191,20 +191,21 @@
463 ('journal', 1, 0, 'text', _('Journal'),None,style_yellow_bold),
464 ]
465 if not group_lines:
466- c_specs += [('partner', 1, 0, 'text', _('Partner'),None,style_yellow_bold),]
467+ c_specs += [('partner', 1, 0, 'text', _('Partner'),None,style_yellow_bold),]
468 c_specs += [
469+ ('ref', 1, 0, 'text', _('Reference'),None,style_yellow_bold),
470 ('label', 1, 0, 'text', _('Label'),None,style_yellow_bold),
471 ('rec', 1, 0, 'text', _('Rec.'),None,style_yellow_bold),
472 ('due_date', 1, 0, 'text', _('Due Date'),None,style_yellow_bold),
473 ('debit', 1, 0, 'text', _('Debit'),None,style_yellow_bold_right),
474 ('credit', 1, 0, 'text', _('Credit'),None,style_yellow_bold_right),
475- ('cumul', 1, 0, 'text', _('Cumul. Bal.'),None,style_yellow_bold_right),
476- ]
477+ ('cumul', 1, 0, 'text', _('Cumul. Bal.'),None,style_yellow_bold_right),
478+ ]
479 if group_lines:
480 c_specs += [
481 ('currbal', 1, 0, 'text', _('Curr. Balance'),None,style_yellow_bold_right),
482 ('curr', 1, 0, 'text', _('Curr.'),None,style_yellow_bold_right),
483- ]
484+ ]
485 else:
486 if _p.amount_currency(data):
487 c_specs += [
488@@ -214,93 +215,94 @@
489 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
490 row_position = self.xls_write_row(ws, row_position, row_data, row_style=style_yellow_bold)
491 return row_position
492-
493+
494 def print_row_code_account(self, regroupmode, account, row_position, partner_name): # Fill in a row with the code and the name of an account + the partner name in case of currency regrouping
495 if regroupmode == "regroup":
496 c_specs = [ ('acc_title', nbr_columns, 0, 'text', ' - '.join([account.code, account.name, partner_name or _('No partner')])), ]
497 else:
498 c_specs = [ ('acc_title', nbr_columns, 0, 'text', ' - '.join([account.code, account.name])), ]
499 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
500- row_position = self.xls_write_row(ws, row_position, row_data, style_account_title)
501- return row_position+1
502-
503- def print_row_partner(self, row_position, partner_name):
504+ row_position = self.xls_write_row(ws, row_position, row_data, style_account_title)
505+ return row_position+1
506+
507+ def print_row_partner(self, row_position, partner_name):
508 c_specs = [ ('partner', nbr_columns, 0, 'text', partner_name or _('No partner')), ]
509 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
510- row_position = self.xls_write_row(ws, row_position, row_data, style_partner_row)
511+ row_position = self.xls_write_row(ws, row_position, row_data, style_partner_row)
512 return row_position
513-
514+
515 def print_group_currency(self, row_position, curr, _p):
516 c_specs = [ ('curr', nbr_columns, 0, 'text', curr or _p.company.currency_id.name), ]
517 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
518- row_position = self.xls_write_row(ws, row_position, row_data, style_bold)
519+ row_position = self.xls_write_row(ws, row_position, row_data, style_bold)
520 return row_position
521
522- def print_lines(self, row_position, account, line,_p, data, line_number): # Fill in rows of invoice line
523-
524+ def print_lines(self, row_position, account, line,_p, data, line_number): # Fill in rows of invoice line
525+
526 label_elements = [line.get('lname') or '']
527 if line.get('invoice_number'):
528 label_elements.append("(%s)" % (line['invoice_number'],))
529 label = ' '.join(label_elements)
530
531- # Mako: <div class="act_as_row lines ${line.get('is_from_previous_periods') and 'open_invoice_previous_line' or ''} ${line.get('is_clearance_line') and 'clearance_line' or ''}">
532+ # Mako: <div class="act_as_row lines ${line.get('is_from_previous_periods') and 'open_invoice_previous_line' or ''} ${line.get('is_clearance_line') and 'clearance_line' or ''}">
533 if line.get('is_from_previous_periods') or line.get('is_clearance_line'):
534 style_line_default = style_default_italic
535- style_line_right = style_right_italic
536+ style_line_right = style_right_italic
537 style_line_date = style_date_italic
538- style_line_decimal = style_decimal_italic
539+ style_line_decimal = style_decimal_italic
540 else:
541 style_line_default = style_default
542- style_line_right = style_right
543+ style_line_right = style_right
544 style_line_date = style_date
545- style_line_decimal = style_decimal
546+ style_line_decimal = style_decimal
547 if line.get('ldate'):
548 c_specs = [('date', 1, 0, 'date', datetime.strptime(line['ldate'],'%Y-%m-%d'), None, style_line_date)]
549 else:
550- c_specs = [('date', 1, 0, 'text', None)]
551- c_specs += [
552+ c_specs = [('date', 1, 0, 'text', None)]
553+ c_specs += [
554 ('period_code', 1, 0, 'text', line.get('period_code') or '' ),
555 ('entry', 1, 0, 'text', line.get('move_name') or '' ),
556 ('journal', 1, 0, 'text', line.get('jcode') or '' ),
557 ('partner', 1, 0, 'text', line.get('partner_name') or '' ),
558+ ('ref', 1, 0, 'text', line.get('lref') or '' ),
559 ('label', 1, 0, 'text', label ),
560 ('rec', 1, 0, 'text', line.get('rec_name') or '' ),
561 ]
562 if line.get('date_maturity'):
563 c_specs += [('datedue', 1, 0, 'date', datetime.strptime(line['date_maturity'],'%Y-%m-%d'), None, style_line_date)]
564 else:
565- c_specs += [('datedue', 1, 0, 'text', None)]
566- c_specs += [
567+ c_specs += [('datedue', 1, 0, 'text', None)]
568+ c_specs += [
569 ('debit', 1, 0, 'number', line.get('debit') or 0.0 , None, style_line_decimal),
570 ('credit', 1, 0, 'number', line.get('credit') or 0.0 , None, style_line_decimal),
571 ]
572-
573+
574 #determine the formula of the cumulated balance
575- debit_cell = rowcol_to_cell(row_position, 8)
576- credit_cell = rowcol_to_cell(row_position, 9)
577- previous_balance = rowcol_to_cell(row_position - 1, 10)
578-
579- if line_number == 1: #if it is the first line, the balance is only debit - credit
580- cumul_balance = debit_cell + '-' + credit_cell
581+ debit_cell = rowcol_to_cell(row_position, 9)
582+ credit_cell = rowcol_to_cell(row_position, 10)
583+ previous_balance = rowcol_to_cell(row_position - 1, 11)
584+
585+ if line_number == 1: #if it is the first line, the balance is only debit - credit
586+ cumul_balance = debit_cell + '-' + credit_cell
587 else: # cumulate debit - credit and balance of previous line
588- cumul_balance = debit_cell + '-' + credit_cell + '+' + previous_balance
589-
590+ cumul_balance = debit_cell + '-' + credit_cell + '+' + previous_balance
591+
592 c_specs += [('cumul', 1, 0, 'number', None, cumul_balance, style_line_decimal)]
593-
594- if _p.amount_currency(data):
595+
596+ if _p.amount_currency(data):
597 if account.currency_id:
598- c_specs += [
599- ('curramount', 1, 0, 'number', line.get('amount_currency') or 0.0, None, style_line_decimal),
600+ c_specs += [
601+ ('curramount', 1, 0, 'number', line.get('amount_currency') or 0.0, None, style_line_decimal),
602 ('currcode', 1, 0, 'text', line['currency_code'], None, style_line_right),
603- ]
604+ ]
605 else:
606 c_specs += [
607- ('curramount', 1, 0, 'text', '-', None, style_line_right),
608- ('currcode', 1, 0, 'text', '', None, style_line_right),
609- ]
610-
611+ ('curramount', 1, 0, 'text', '-', None, style_line_right),
612+ ('currcode', 1, 0, 'text', '', None, style_line_right),
613+ ]
614+
615 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
616- row_position = self.xls_write_row(ws, row_position, row_data, style_line_default)
617+ row_position = self.xls_write_row(ws, row_position, row_data, style_line_default)
618 return row_position
619
620 def print_group_lines(self, row_position, account, line,_p, line_number): # Fill in rows of invoice line when the option currency regroup is selected
621@@ -309,135 +311,136 @@
622 if line.get('invoice_number'):
623 label_elements.append("(%s)" % (line['invoice_number'],))
624 label = ' '.join(label_elements)
625- # Mako: <div class="act_as_row lines ${line.get('is_from_previous_periods') and 'open_invoice_previous_line' or ''} ${line.get('is_clearance_line') and 'clearance_line' or ''}">
626+ # Mako: <div class="act_as_row lines ${line.get('is_from_previous_periods') and 'open_invoice_previous_line' or ''} ${line.get('is_clearance_line') and 'clearance_line' or ''}">
627 if line.get('is_from_previous_periods') or line.get('is_clearance_line'):
628 style_line_default = style_default_italic
629- style_line_right = style_right_italic
630+ style_line_right = style_right_italic
631 style_line_date = style_date_italic
632- style_line_decimal = style_decimal_italic
633+ style_line_decimal = style_decimal_italic
634 else:
635 style_line_default = style_default
636- style_line_right = style_right
637+ style_line_right = style_right
638 style_line_date = style_date
639- style_line_decimal = style_decimal
640-
641- debit_cell = rowcol_to_cell(row_position, 7)
642- credit_cell = rowcol_to_cell(row_position, 8)
643- previous_balance = rowcol_to_cell(row_position - 1, 9)
644-
645- if line_number == 1: #if it is the first line, the balance is only debit - credit
646- cumul_balance = debit_cell + '-' + credit_cell
647+ style_line_decimal = style_decimal
648+
649+ debit_cell = rowcol_to_cell(row_position, 8)
650+ credit_cell = rowcol_to_cell(row_position, 9)
651+ previous_balance = rowcol_to_cell(row_position - 1, 10)
652+
653+ if line_number == 1: #if it is the first line, the balance is only debit - credit
654+ cumul_balance = debit_cell + '-' + credit_cell
655 else: # cumulate devit - credit and balance of previous line
656- cumul_balance = debit_cell + '-' + credit_cell + '+' + previous_balance
657+ cumul_balance = debit_cell + '-' + credit_cell + '+' + previous_balance
658
659 if line.get('ldate'):
660 c_specs = [('date', 1, 0, 'date', datetime.strptime(line['ldate'],'%Y-%m-%d'), None, style_line_date)]
661 else:
662- c_specs = [('date', 1, 0, 'text', None)]
663- c_specs += [
664+ c_specs = [('date', 1, 0, 'text', None)]
665+ c_specs += [
666 ('period_code', 1, 0, 'text', line.get('period_code') or '' ),
667 ('entry', 1, 0, 'text', line.get('move_name') or '' ),
668- ('journal', 1, 0, 'text', line.get('jcode') or '' ),
669+ ('journal', 1, 0, 'text', line.get('jcode') or '' ),
670+ ('ref', 1, 0, 'text', line.get('lref') or '' ),
671 ('label', 1, 0, 'text', label),
672 ('rec', 1, 0, 'text', line.get('rec_name') or '' ),
673 ]
674 if line.get('date_maturity'):
675 c_specs += [('datedue', 1, 0, 'date', datetime.strptime(line['date_maturity'],'%Y-%m-%d'), None, style_line_date)]
676 else:
677- c_specs += [('datedue', 1, 0, 'text', None)]
678- c_specs += [
679+ c_specs += [('datedue', 1, 0, 'text', None)]
680+ c_specs += [
681 ('debit', 1, 0, 'number', line.get('debit') or 0.0, None, style_line_decimal),
682- ('credit', 1, 0, 'number', line.get('credit') or 0.0, None, style_line_decimal),
683- ('cumul', 1, 0, 'number', None, cumul_balance, style_line_decimal),
684+ ('credit', 1, 0, 'number', line.get('credit') or 0.0, None, style_line_decimal),
685+ ('cumul', 1, 0, 'number', None, cumul_balance, style_line_decimal),
686 ]
687 if account.currency_id:
688- c_specs += [
689- ('curramount', 1, 0, 'number', line.get('amount_currency') or 0.0, None, style_line_decimal),
690- ('currcode', 1, 0, 'text', line.get('currency_code') or '', None, style_line_right),
691+ c_specs += [
692+ ('curramount', 1, 0, 'number', line.get('amount_currency') or 0.0, None, style_line_decimal),
693+ ('currcode', 1, 0, 'text', line.get('currency_code') or '', None, style_line_right),
694 ]
695 else:
696 c_specs += [
697- ('curramount', 1, 0, 'text', '-', None, style_line_right),
698- ('currcode', 1, 0, 'text', '', None, style_line_right),
699- ]
700-
701+ ('curramount', 1, 0, 'text', '-', None, style_line_right),
702+ ('currcode', 1, 0, 'text', '', None, style_line_right),
703+ ]
704+
705 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
706- row_position = self.xls_write_row(ws, row_position, row_data, style_line_default)
707- return (row_position, cumul_balance)
708-
709+ row_position = self.xls_write_row(ws, row_position, row_data, style_line_default)
710+ return (row_position, cumul_balance)
711+
712 def print_cumul_partner(self, row_position, row_start_partner, account, _p, data): #print by partner the totals and cumulated balance (Excel formulas)
713
714- start_col = 5 #the text "Cumulated Balance on Partner starts in column 4 when selecting the option regroup by currency, 5 in the other case
715-
716- debit_partner_start = rowcol_to_cell(row_start_partner, start_col + 3)
717+ start_col = 6 #the text "Cumulated Balance on Partner starts in column 5 when selecting the option regroup by currency, 6 in the other case
718+
719+ debit_partner_start = rowcol_to_cell(row_start_partner, start_col + 3)
720 debit_partner_end = rowcol_to_cell(row_position-1, start_col + 3)
721 debit_partner_total = 'SUM(' + debit_partner_start + ':' + debit_partner_end + ')'
722-
723- credit_partner_start = rowcol_to_cell(row_start_partner, start_col + 4)
724+
725+ credit_partner_start = rowcol_to_cell(row_start_partner, start_col + 4)
726 credit_partner_end = rowcol_to_cell(row_position-1, start_col + 4)
727 credit_partner_total = 'SUM(' + credit_partner_start + ':' + credit_partner_end + ')'
728-
729+
730 bal_curr_start = rowcol_to_cell(row_start_partner, start_col + 6)
731 bal_curr_end = rowcol_to_cell(row_position-1, start_col + 6)
732- cumul_balance_curr = 'SUM(' + bal_curr_start + ':' + bal_curr_end + ')'
733-
734-
735- bal_partner_debit = rowcol_to_cell(row_position, start_col + 3)
736+ cumul_balance_curr = 'SUM(' + bal_curr_start + ':' + bal_curr_end + ')'
737+
738+
739+ bal_partner_debit = rowcol_to_cell(row_position, start_col + 3)
740 bal_partner_credit = rowcol_to_cell(row_position, start_col + 4)
741- bal_partner_total = bal_partner_debit + '-' + bal_partner_credit
742-
743+ bal_partner_total = bal_partner_debit + '-' + bal_partner_credit
744+
745 c_specs = [('empty%s' %x, 1, 0, 'text', None) for x in range(start_col)]
746-
747+
748 c_specs += [
749 ('init_bal', 1, 0, 'text', _('Cumulated Balance on Partner')),
750 ('rec', 1, 0, 'text', None),
751 ('empty5', 1, 0, 'text', None),
752- ('debit', 1, 0, 'number', None, debit_partner_total, style_partner_cumul_decimal),
753- ('credit', 1, 0, 'number', None, credit_partner_total, style_partner_cumul_decimal),
754+ ('debit', 1, 0, 'number', None, debit_partner_total, style_partner_cumul_decimal),
755+ ('credit', 1, 0, 'number', None, credit_partner_total, style_partner_cumul_decimal),
756 ('cumul_bal', 1, 0, 'number', None, bal_partner_total, style_partner_cumul_decimal),
757 ]
758 if _p.amount_currency(data):
759 if account.currency_id:
760 c_specs += [('cumul_bal_curr', 1, 0, 'number', None, cumul_balance_curr, style_partner_cumul_decimal),
761 ('curr_name', 1, 0, 'text', account.currency_id.name, None, style_partner_cumul_right),
762- ]
763- else:
764+ ]
765+ else:
766 c_specs += [('cumul_bal_curr', 1, 0, 'text', '-', None, style_partner_cumul_right),
767 ('curr_name', 1, 0, 'text', '', None, style_partner_cumul_right)
768- ]
769-
770+ ]
771+
772 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
773- row_position = self.xls_write_row(ws, row_position, row_data, style_partner_cumul)
774- return row_position+1
775-
776+ row_position = self.xls_write_row(ws, row_position, row_data, style_partner_cumul)
777+ return row_position+1
778+
779 def print_group_cumul_partner(self,row_position, row_start_partner, account, _p, data): #print by partner the totals and cumulated balance (Excel formulas) when the option currency regroup is selected
780
781- start_col = 4 #the text "Cumulated Balance on Partner starts in column 4 when selecting the option regroup by currency, 5 in the other case
782-
783- debit_partner_start = rowcol_to_cell(row_start_partner, start_col + 3)
784+ start_col = 5 #the text "Cumulated Balance on Partner starts in column 5 when selecting the option regroup by currency, 6 in the other case
785+
786+ debit_partner_start = rowcol_to_cell(row_start_partner, start_col + 3)
787 debit_partner_end = rowcol_to_cell(row_position-1, start_col + 3)
788 debit_partner_total = 'SUM(' + debit_partner_start + ':' + debit_partner_end + ')'
789-
790- credit_partner_start = rowcol_to_cell(row_start_partner, start_col + 4)
791+
792+ credit_partner_start = rowcol_to_cell(row_start_partner, start_col + 4)
793 credit_partner_end = rowcol_to_cell(row_position-1, start_col + 4)
794 credit_partner_total = 'SUM(' + credit_partner_start + ':' + credit_partner_end + ')'
795-
796+
797 bal_curr_start = rowcol_to_cell(row_start_partner, start_col + 5)
798 bal_curr_end = rowcol_to_cell(row_position-1, start_col + 5)
799- cumul_balance_curr = 'SUM(' + bal_curr_start + ':' + bal_curr_end + ')'
800-
801- bal_partner_debit = rowcol_to_cell(row_position, start_col + 3)
802+ cumul_balance_curr = 'SUM(' + bal_curr_start + ':' + bal_curr_end + ')'
803+
804+ bal_partner_debit = rowcol_to_cell(row_position, start_col + 3)
805 bal_partner_credit = rowcol_to_cell(row_position, start_col + 4)
806- bal_partner_total = bal_partner_debit + '-' + bal_partner_credit
807-
808+ bal_partner_total = bal_partner_debit + '-' + bal_partner_credit
809+
810 c_specs = [('empty%s' %x, 1, 0, 'text', None) for x in range(start_col)]
811-
812+
813 c_specs += [
814 ('init_bal', 1, 0, 'text', _('Cumulated Balance on Partner')), #, style_bold_italic),
815 ('rec', 1, 0, 'text', None),
816 ('empty5', 1, 0, 'text', None),
817- ('debit', 1, 0, 'number', None, debit_partner_total, style_partner_cumul_decimal),
818- ('credit', 1, 0, 'number', None, credit_partner_total, style_partner_cumul_decimal),
819+ ('debit', 1, 0, 'number', None, debit_partner_total, style_partner_cumul_decimal),
820+ ('credit', 1, 0, 'number', None, credit_partner_total, style_partner_cumul_decimal),
821 ('cumul_bal', 1, 0, 'number', None, bal_partner_total, style_partner_cumul_decimal),
822 ]
823 if account.currency_id:
824@@ -449,38 +452,38 @@
825 c_specs += [
826 ('cumul_bal_curr', 1, 0, 'text', "-", None, style_partner_cumul_right),
827 ('curr_name', 1, 0, 'text', "", None, style_partner_cumul_right),
828- ]
829+ ]
830 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
831- row_position = self.xls_write_row(ws, row_position, row_data, style_partner_cumul)
832- return row_position+1
833-
834+ row_position = self.xls_write_row(ws, row_position, row_data, style_partner_cumul)
835+ return row_position+1
836+
837 def print_cumul_account(self, row_position, row_start_account, account, _p, data): #print by account the totals of the credit and debit + balance calculation
838-
839+
840 #This procedure will create an Excel sumif function that will check in the column "label" for the "Cumulated Balance.." string and make a sum of the debit & credit data
841- start_col = 5 #the text "Cumulated Balance on Partner starts in column 4 when selecting the option regroup by currency, 5 in the other case
842-
843- reference_start = rowcol_to_cell(row_start_account, start_col) #range in which we search for the text "Cumulated Balance on Partner"
844+ start_col = 6 #the text "Cumulated Balance on Partner starts in column 5 when selecting the option regroup by currency, 6 in the other case
845+
846+ reference_start = rowcol_to_cell(row_start_account, start_col) #range in which we search for the text "Cumulated Balance on Partner"
847 reference_stop = rowcol_to_cell(row_position -1 , start_col)
848-
849+
850 range_debit_start = rowcol_to_cell(row_start_account, start_col + 3) #range in which we make the sum of all the cumulated balance lines (debit)
851- range_debit_stop = rowcol_to_cell(row_position -1, start_col + 3)
852-
853+ range_debit_stop = rowcol_to_cell(row_position -1, start_col + 3)
854+
855 range_credit_start = rowcol_to_cell(row_start_account, start_col + 4) #range in which we make the sum of all the cumulated balance lines (crebit)
856- range_credit_stop = rowcol_to_cell(row_position -1, start_col + 4)
857-
858+ range_credit_stop = rowcol_to_cell(row_position -1, start_col + 4)
859+
860 search_key = _('Cumulated Balance on Partner')
861 total_debit_account = 'SUMIF(' + reference_start + ':' + reference_stop + ';"' + search_key + '";' + range_debit_start + ':' + range_debit_stop + ')'
862 total_credit_account = 'SUMIF(' + reference_start + ':' + reference_stop + ';"' + search_key + '";' + range_credit_start + ':' + range_credit_stop + ')'
863-
864- bal_account_debit = rowcol_to_cell(row_position, start_col + 3)
865+
866+ bal_account_debit = rowcol_to_cell(row_position, start_col + 3)
867 bal_account_credit = rowcol_to_cell(row_position, start_col + 4)
868- bal_account_total = bal_account_debit + '-' + bal_account_credit
869-
870+ bal_account_total = bal_account_debit + '-' + bal_account_credit
871+
872 bal_curr_start = rowcol_to_cell(row_start_account, start_col + 6)
873 bal_curr_end = rowcol_to_cell(row_position-1, start_col + 6)
874 cumul_balance_curr = 'SUMIF(' + reference_start + ':' + reference_stop + ';"' + search_key + '";' + bal_curr_start + ':' + bal_curr_end + ')'
875-
876- c_specs = [
877+
878+ c_specs = [
879 ('acc_title', start_col, 0, 'text', ' - '.join([account.code, account.name])),
880 ('init_bal', 2, 0, 'text', _('Cumulated Balance on Account')),
881 ('empty2', 1, 0, 'text', None),
882@@ -492,41 +495,41 @@
883 if account.currency_id:
884 c_specs += [('cumul_bal_curr', 1, 0, 'number', None, cumul_balance_curr),
885 ('curr_name', 1, 0, 'text', account.currency_id.name, None, style_account_title_right),
886- ]
887- else:
888+ ]
889+ else:
890 c_specs += [('cumul_bal_curr', 1, 0, 'text', "-", None, style_account_title_right),
891 ('curr_name', 1, 0, 'text', "", None, style_account_title_right)
892- ]
893+ ]
894 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
895- row_position = self.xls_write_row(ws, row_position, row_data, style_account_title)
896- return row_position+1
897-
898- def print_group_cumul_account(self,row_position, row_start_account, account): #print by account the totals of the credit and debit + balance calculation
899- #This procedure will create an Excel sumif function that will check in the column "label" for the "Cumulated Balance.." string and make a sum of the debit & credit data
900- start_col = 4 #the text "Cumulated Balance on Partner starts in column 4 when selecting the option regroup by currency, 5 in the other case
901-
902- reference_start = rowcol_to_cell(row_start_account, start_col) #range in which we search for the text "Cumulated Balance on Partner"
903+ row_position = self.xls_write_row(ws, row_position, row_data, style_account_title)
904+ return row_position+1
905+
906+ def print_group_cumul_account(self,row_position, row_start_account, account): #print by account the totals of the credit and debit + balance calculation
907+ #This procedure will create an Excel sumif function that will check in the column "label" for the "Cumulated Balance.." string and make a sum of the debit & credit data
908+ start_col = 5 #the text "Cumulated Balance on Partner starts in column 5 when selecting the option regroup by currency, 6 in the other case
909+
910+ reference_start = rowcol_to_cell(row_start_account, start_col) #range in which we search for the text "Cumulated Balance on Partner"
911 reference_stop = rowcol_to_cell(row_position -1 , start_col)
912-
913+
914 range_debit_start = rowcol_to_cell(row_start_account, start_col + 3) #range in which we make the sum of all the cumulated balance lines (debit)
915- range_debit_stop = rowcol_to_cell(row_position -1, start_col + 3)
916-
917+ range_debit_stop = rowcol_to_cell(row_position -1, start_col + 3)
918+
919 range_credit_start = rowcol_to_cell(row_start_account, start_col + 4) #range in which we make the sum of all the cumulated balance lines (crebit)
920- range_credit_stop = rowcol_to_cell(row_position -1, start_col + 4)
921-
922+ range_credit_stop = rowcol_to_cell(row_position -1, start_col + 4)
923+
924 search_key = _('Cumulated Balance on Partner')
925 total_debit_account = 'SUMIF(' + reference_start + ':' + reference_stop + ';"' + search_key + '";' + range_debit_start + ':' + range_debit_stop + ')'
926 total_credit_account = 'SUMIF(' + reference_start + ':' + reference_stop + ';"' + search_key + '";' + range_credit_start + ':' + range_credit_stop + ')'
927-
928- bal_account_debit = rowcol_to_cell(row_position, start_col + 3)
929+
930+ bal_account_debit = rowcol_to_cell(row_position, start_col + 3)
931 bal_account_credit = rowcol_to_cell(row_position, start_col + 4)
932- bal_account_total = bal_account_debit + '-' + bal_account_credit
933-
934+ bal_account_total = bal_account_debit + '-' + bal_account_credit
935+
936 bal_curr_start = rowcol_to_cell(row_start_account, start_col + 6)
937 bal_curr_end = rowcol_to_cell(row_position-1, start_col + 6)
938 cumul_balance_curr = 'SUMIF(' + reference_start + ':' + reference_stop + ';"' + search_key + '";' + bal_curr_start + ':' + bal_curr_end + ')'
939-
940- c_specs = [
941+
942+ c_specs = [
943 ('acc_title', start_col, 0, 'text', ' - '.join([account.code, account.name])),
944 ('init_bal', 2, 0, 'text', _('Cumulated Balance on Account')),
945 ('empty2', 1, 0, 'text', None),
946@@ -537,28 +540,28 @@
947 if account.currency_id:
948 c_specs += [('cumul_bal_curr', 1, 0, 'number', None, cumul_balance_curr, style_account_title_decimal),
949 ('curr_name', 1, 0, 'text', account.currency_id.name, None, style_account_title_decimal),
950- ]
951- else:
952+ ]
953+ else:
954 c_specs += [('cumul_bal_curr', 1, 0, 'text', "-", None, style_account_title_right),
955 ('curr_name', 1, 0, 'text', "", None, style_account_title_right)
956- ]
957+ ]
958 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
959- row_position = self.xls_write_row(ws, row_position, row_data, style_account_title)
960- return row_position+1
961-
962+ row_position = self.xls_write_row(ws, row_position, row_data, style_account_title)
963+ return row_position+1
964+
965 def print_grouped_line_report(self, row_pos, account, _xs, xlwt, _p, data): # export the invoice AR/AP lines when the option currency regroup is selected
966-
967+
968 if account.grouped_ledger_lines and account.partners_order:
969- row_start_account = row_pos
970-
971+ row_start_account = row_pos
972+
973 for partner_name, p_id, p_ref, p_name in account.partners_order:
974- row_pos = self.print_row_code_account("regroup", account,row_pos, partner_name)
975-
976+ row_pos = self.print_row_code_account("regroup", account,row_pos, partner_name)
977+
978 for curr, grouped_lines in account.grouped_ledger_lines.get(p_id, []):
979-
980+
981 row_pos = self.print_group_currency(row_pos, curr, _p)
982- # Print row: Titles "Date-Period-Entry-Journal..."
983- row_pos = self.print_columns_title(_p, row_pos, data, group_lines=True)
984+ # Print row: Titles "Date-Period-Entry-Journal..."
985+ row_pos = self.print_columns_title(_p, row_pos, data, group_lines=True)
986
987 row_pos_start = row_pos
988 line_number = 0
989@@ -566,62 +569,62 @@
990 line_number += 1
991 row_pos, cumul_balance = self.print_group_lines(row_pos, account, line, _p, line_number)
992 row_pos = self.print_group_cumul_partner(row_pos,row_pos_start, account, _p, data)
993-
994+
995 row_pos = self.print_group_cumul_account(row_pos, row_start_account, account)
996-
997+
998 return row_pos
999-
1000+
1001 def print_ledger_lines(self, row_pos, account, _xs, xlwt, _p, data): # export the invoice AR/AP lines
1002
1003 if account.ledger_lines and account.partners_order:
1004 row_start_account = row_pos
1005-
1006+
1007 #Print account line: code - account
1008- row_pos = self.print_row_code_account("noregroup",account,row_pos, "")
1009+ row_pos = self.print_row_code_account("noregroup",account,row_pos, "")
1010 for partner_name, p_id, p_ref, p_name in account.partners_order:
1011-
1012+
1013 #Print partner row
1014 row_pos = self.print_row_partner(row_pos, partner_name)
1015- # Print row: Titles "Date-Period-Entry-Journal..."
1016- row_pos = self.print_columns_title(_p, row_pos, data, group_lines=False)
1017-
1018+ # Print row: Titles "Date-Period-Entry-Journal..."
1019+ row_pos = self.print_columns_title(_p, row_pos, data, group_lines=False)
1020+
1021 row_pos_start = row_pos
1022 line_number = 0
1023 for line in account.ledger_lines.get(p_id, []):
1024 line_number += 1
1025 # print ledger lines
1026 row_pos = self.print_lines(row_pos, account, line, _p, data, line_number)
1027- row_pos = self.print_cumul_partner(row_pos, row_pos_start, account, _p, data)
1028-
1029+ row_pos = self.print_cumul_partner(row_pos, row_pos_start, account, _p, data)
1030+
1031 row_pos = self.print_cumul_account(row_pos, row_start_account, account, _p, data)
1032-
1033+
1034 return row_pos
1035-
1036+
1037 def generate_xls_report(self, _p, _xs, data, objects, wb): # main function
1038-
1039+
1040 # Initializations
1041 self.global_initializations(wb,_p, xlwt, _xs, objects, data)
1042- row_pos = 0
1043+ row_pos = 0
1044 # Print Title
1045- row_pos = self.print_title(_p, row_pos)
1046+ row_pos = self.print_title(_p, row_pos)
1047 # Print empty row to define column sizes
1048- row_pos = self.print_empty_row(row_pos)
1049+ row_pos = self.print_empty_row(row_pos)
1050 # Print Header Table titles (Fiscal Year - Accounts Filter - Periods Filter...)
1051 row_pos = self.print_header_titles(_p, data, row_pos)
1052 # Print Header Table data
1053 row_pos = self.print_header_data(_p, data, row_pos)
1054 #Freeze the line
1055- ws.set_horz_split_pos(row_pos)
1056+ ws.set_horz_split_pos(row_pos)
1057 # Print empty row
1058 row_pos = self.print_empty_row(row_pos)
1059-
1060- for acc in objects:
1061+
1062+ for acc in objects:
1063 if hasattr(acc, 'grouped_ledger_lines'):
1064 # call xls equivalent of "grouped_by_curr_open_invoices_inclusion.mako.html"
1065 row_pos = self.print_grouped_line_report(row_pos, acc, _xs, xlwt, _p, data)
1066 else:
1067- # call xls equivalent of "open_invoices_inclusion.mako.html"
1068+ # call xls equivalent of "open_invoices_inclusion.mako.html"
1069 row_pos = self.print_ledger_lines(row_pos, acc, _xs, xlwt, _p, data)
1070 row_pos += 1
1071-
1072+
1073 open_invoices_xls('report.account.account_report_open_invoices_xls', 'account.account', parser=PartnersOpenInvoicesWebkit)
1074
1075=== modified file 'account_financial_report_webkit_xls/report/partner_ledger_xls.py'
1076--- account_financial_report_webkit_xls/report/partner_ledger_xls.py 2013-10-31 18:01:41 +0000
1077+++ account_financial_report_webkit_xls/report/partner_ledger_xls.py 2014-04-11 09:05:21 +0000
1078@@ -37,32 +37,33 @@
1079 ('move', 20),
1080 ('journal', 12),
1081 ('partner', 30),
1082+ ('ref', 20),
1083 ('label', 58),
1084 ('rec', 12),
1085- ('debit', 15),
1086+ ('debit', 15),
1087 ('credit', 15),
1088 ('cumul_bal', 15),
1089- ('curr_bal', 15),
1090+ ('curr_bal', 15),
1091 ('curr_code', 7),
1092 ]
1093
1094 class partner_ledger_xls(report_xls):
1095 column_sizes = [x[1] for x in _column_sizes]
1096-
1097+
1098 def generate_xls_report(self, _p, _xs, data, objects, wb):
1099-
1100+
1101 ws = wb.add_sheet(_p.report_name[:31])
1102 ws.panes_frozen = True
1103 ws.remove_splits = True
1104 ws.portrait = 0 # Landscape
1105 ws.fit_width_to_pages = 1
1106 row_pos = 0
1107-
1108+
1109 # set print header/footer
1110 ws.header_str = self.xls_headers['standard']
1111 ws.footer_str = self.xls_footers['standard']
1112-
1113- # cf. account_report_partner_ledger.mako
1114+
1115+ # cf. account_report_partner_ledger.mako
1116 initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')}
1117
1118 # Title
1119@@ -70,7 +71,7 @@
1120 report_name = ' - '.join([_p.report_name.upper(), _p.company.partner_id.name, _p.company.currency_id.name])
1121 c_specs = [
1122 ('report_name', 1, 0, 'text', report_name),
1123- ]
1124+ ]
1125 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
1126 row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style)
1127
1128@@ -78,24 +79,24 @@
1129 c_sizes = self.column_sizes
1130 c_specs = [('empty%s'%i, 1, c_sizes[i], 'text', None) for i in range(0,len(c_sizes))]
1131 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
1132- row_pos = self.xls_write_row(ws, row_pos, row_data, set_column_size=True)
1133-
1134+ row_pos = self.xls_write_row(ws, row_pos, row_data, set_column_size=True)
1135+
1136 # Header Table
1137- nbr_columns = 10
1138+ nbr_columns = 11
1139 if _p.amount_currency(data):
1140- nbr_columns = 12
1141+ nbr_columns = 13
1142 cell_format = _xs['bold'] + _xs['fill_blue'] + _xs['borders_all']
1143 cell_style = xlwt.easyxf(cell_format)
1144 cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
1145 c_specs = [
1146 ('coa', 2, 0, 'text', _('Chart of Account')),
1147- ('fy', 1, 0, 'text', _('Fiscal Year')),
1148+ ('fy', 2, 0, 'text', _('Fiscal Year')),
1149 ('df', 2, 0, 'text', _p.filter_form(data) == 'filter_date' and _('Dates Filter') or _('Periods Filter')),
1150- ('af', 1, 0, 'text', _('Accounts Filter')),
1151+ ('af', 2, 0, 'text', _('Accounts Filter')),
1152 ('tm', 2, 0, 'text', _('Target Moves')),
1153- ('ib', nbr_columns-8, 0, 'text', _('Initial Balance')),
1154+ ('ib', nbr_columns-10, 0, 'text', _('Initial Balance')),
1155
1156- ]
1157+ ]
1158 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
1159 row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style_center)
1160
1161@@ -104,11 +105,11 @@
1162 cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
1163 c_specs = [
1164 ('coa', 2, 0, 'text', _p.chart_account.name),
1165- ('fy', 1, 0, 'text', _p.fiscalyear.name if _p.fiscalyear else '-'),
1166+ ('fy', 2, 0, 'text', _p.fiscalyear.name if _p.fiscalyear else '-'),
1167 ]
1168 df = _('From') + ': '
1169 if _p.filter_form(data) == 'filter_date':
1170- df += _p.start_date if _p.start_date else u''
1171+ df += _p.start_date if _p.start_date else u''
1172 else:
1173 df += _p.start_period.name if _p.start_period else u''
1174 df += ' ' + _('To') + ': '
1175@@ -118,19 +119,19 @@
1176 df += _p.stop_period.name if _p.stop_period else u''
1177 c_specs += [
1178 ('df', 2, 0, 'text', df),
1179- ('af', 1, 0, 'text', _('Custom Filter') if _p.partner_ids else _p.display_partner_account(data)),
1180+ ('af', 2, 0, 'text', _('Custom Filter') if _p.partner_ids else _p.display_partner_account(data)),
1181 ('tm', 2, 0, 'text', _p.display_target_move(data)),
1182- ('ib', nbr_columns-8, 0, 'text', initial_balance_text[_p.initial_balance_mode]),
1183- ]
1184+ ('ib', nbr_columns-10, 0, 'text', initial_balance_text[_p.initial_balance_mode]),
1185+ ]
1186 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
1187- row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style_center)
1188- ws.set_horz_split_pos(row_pos)
1189+ row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style_center)
1190+ ws.set_horz_split_pos(row_pos)
1191 row_pos += 1
1192
1193 # Account Title Row
1194 cell_format = _xs['xls_title'] + _xs['bold'] + _xs['fill'] + _xs['borders_all']
1195 account_cell_style = xlwt.easyxf(cell_format)
1196- account_cell_style_right = xlwt.easyxf(cell_format + _xs['right'])
1197+ account_cell_style_right = xlwt.easyxf(cell_format + _xs['right'])
1198 account_cell_style_decimal = xlwt.easyxf(cell_format + _xs['right'], num_format_str = report_xls.decimal_format)
1199
1200 # Column Title Row
1201@@ -150,29 +151,30 @@
1202 c_init_cell_style_right = xlwt.easyxf(cell_format + _xs['right'])
1203 c_init_cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
1204 c_init_cell_style_decimal = xlwt.easyxf(cell_format + _xs['right'], num_format_str = report_xls.decimal_format)
1205-
1206+
1207 # Column Cumulated balance Row
1208 cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all']
1209 c_cumul_cell_style = xlwt.easyxf(cell_format)
1210 c_cumul_cell_style_right = xlwt.easyxf(cell_format + _xs['right'])
1211 c_cumul_cell_style_center = xlwt.easyxf(cell_format + _xs['center'])
1212 c_cumul_cell_style_decimal = xlwt.easyxf(cell_format + _xs['right'], num_format_str = report_xls.decimal_format)
1213-
1214+
1215 # Column Partner Row
1216 cell_format = _xs['bold']
1217 c_part_cell_style = xlwt.easyxf(cell_format)
1218-
1219+
1220 c_specs = [
1221 ('date', 1, 0, 'text', _('Date'), None, c_hdr_cell_style),
1222 ('period', 1, 0, 'text', _('Period'), None, c_hdr_cell_style),
1223 ('move', 1, 0, 'text', _('Entry'), None, c_hdr_cell_style),
1224 ('journal', 1, 0, 'text', _('Journal'), None, c_hdr_cell_style),
1225 ('partner', 1, 0, 'text', _('Partner'), None, c_hdr_cell_style),
1226+ ('ref', 1, 0, 'text', _('Reference'), None, c_hdr_cell_style),
1227 ('label', 1, 0, 'text', _('Label'), None, c_hdr_cell_style),
1228 ('rec', 1, 0, 'text', _('Rec.'), None, c_hdr_cell_style),
1229 ('debit', 1, 0, 'text', _('Debit'), None, c_hdr_cell_style_right),
1230 ('credit', 1, 0, 'text', _('Credit'), None, c_hdr_cell_style_right),
1231- ('cumul_bal', 1, 0, 'text', _('Cumul. Bal.'), None, c_hdr_cell_style_right),
1232+ ('cumul_bal', 1, 0, 'text', _('Cumul. Bal.'), None, c_hdr_cell_style_right),
1233 ]
1234 if _p.amount_currency(data):
1235 c_specs += [
1236@@ -188,10 +190,10 @@
1237 ll_cell_style_center = xlwt.easyxf(ll_cell_format + _xs['center'])
1238 ll_cell_style_date = xlwt.easyxf(ll_cell_format + _xs['left'], num_format_str = report_xls.date_format)
1239 ll_cell_style_decimal = xlwt.easyxf(ll_cell_format + _xs['right'], num_format_str = report_xls.decimal_format)
1240-
1241+
1242 cnt = 0
1243 for account in objects:
1244- if account.ledger_lines or account.init_balance:
1245+ if account.ledger_lines or account.init_balance:
1246 if not account.partners_order:
1247 continue
1248 cnt += 1
1249@@ -203,12 +205,12 @@
1250 ('acc_title', nbr_columns, 0, 'text', ' - '.join([account.code, account.name]), None, account_cell_style),
1251 ]
1252 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
1253- row_pos = self.xls_write_row(ws, row_pos, row_data, c_title_cell_style)
1254+ row_pos = self.xls_write_row(ws, row_pos, row_data, c_title_cell_style)
1255 row_pos += 1
1256 row_start_account = row_pos
1257-
1258+
1259 for partner_name, p_id, p_ref, p_name in account.partners_order:
1260-
1261+
1262 total_debit = 0.0
1263 total_credit = 0.0
1264 cumul_balance = 0.0
1265@@ -219,17 +221,17 @@
1266 ('partner_title', nbr_columns, 0, 'text', partner_name or _('No Partner'), None, c_part_cell_style),
1267 ]
1268 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
1269- row_pos = self.xls_write_row(ws, row_pos, row_data, c_title_cell_style)
1270- row_pos = self.xls_write_row(ws, row_pos, c_hdr_data)
1271+ row_pos = self.xls_write_row(ws, row_pos, row_data, c_title_cell_style)
1272+ row_pos = self.xls_write_row(ws, row_pos, c_hdr_data)
1273 row_start_partner = row_pos
1274
1275 total_debit = account.init_balance.get(p_id, {}).get('debit') or 0.0
1276 total_credit = account.init_balance.get(p_id, {}).get('credit') or 0.0
1277-
1278+
1279 init_line = False
1280 if _p.initial_balance_mode and (total_debit or total_credit):
1281 init_line = True
1282-
1283+
1284 part_cumul_balance = account.init_balance.get(p_id, {}).get('init_balance') or 0.0
1285 part_cumul_balance_curr = account.init_balance.get(p_id, {}).get('init_balance_currency') or 0.0
1286 balance_forward_currency = account.init_balance.get(p_id, {}).get('currency_name') or ''
1287@@ -237,27 +239,27 @@
1288 cumul_balance += part_cumul_balance
1289 cumul_balance_curr += part_cumul_balance_curr
1290
1291- debit_cell = rowcol_to_cell(row_pos, 7)
1292- credit_cell = rowcol_to_cell(row_pos, 8)
1293- init_bal_formula = debit_cell + '-' + credit_cell
1294-
1295- ################## Print row 'Initial Balance' by partner #################
1296- c_specs = [('empty%s' %x, 1, 0, 'text', None) for x in range(5)]
1297+ debit_cell = rowcol_to_cell(row_pos, 8)
1298+ credit_cell = rowcol_to_cell(row_pos, 9)
1299+ init_bal_formula = debit_cell + '-' + credit_cell
1300+
1301+ ################## Print row 'Initial Balance' by partner #################
1302+ c_specs = [('empty%s' %x, 1, 0, 'text', None) for x in range(6)]
1303 c_specs += [
1304 ('init_bal', 1, 0, 'text', _('Initial Balance')),
1305 ('rec', 1, 0, 'text', None),
1306 ('debit', 1, 0, 'number', total_debit, None, c_init_cell_style_decimal),
1307 ('credit', 1, 0, 'number', total_credit, None, c_init_cell_style_decimal),
1308- ('cumul_bal', 1, 0, 'number', None, init_bal_formula, c_init_cell_style_decimal),
1309- ]
1310+ ('cumul_bal', 1, 0, 'number', None, init_bal_formula, c_init_cell_style_decimal),
1311+ ]
1312 if _p.amount_currency(data):
1313 c_specs += [
1314 ('curr_bal', 1, 0, 'number', part_cumul_balance_curr, None, c_init_cell_style_decimal),
1315 ('curr_code', 1, 0, 'text', balance_forward_currency),
1316 ]
1317 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
1318- row_pos = self.xls_write_row(ws, row_pos, row_data, c_init_cell_style)
1319-
1320+ row_pos = self.xls_write_row(ws, row_pos, row_data, c_init_cell_style)
1321+
1322 for line in account.ledger_lines.get(p_id, []):
1323
1324 total_debit += line.get('debit') or 0.0
1325@@ -268,16 +270,16 @@
1326 label_elements.append("(%s)" % (line['invoice_number'],))
1327 label = ' '.join(label_elements)
1328 cumul_balance += line.get('balance') or 0.0
1329-
1330+
1331 if init_line or row_pos > row_start_partner:
1332 cumbal_formula = rowcol_to_cell(row_pos-1, 9) + '+'
1333 else:
1334 cumbal_formula = ''
1335- debit_cell = rowcol_to_cell(row_pos, 7)
1336- credit_cell = rowcol_to_cell(row_pos, 8)
1337- cumbal_formula += debit_cell + '-' + credit_cell
1338+ debit_cell = rowcol_to_cell(row_pos, 8)
1339+ credit_cell = rowcol_to_cell(row_pos, 9)
1340+ cumbal_formula += debit_cell + '-' + credit_cell
1341 ################## Print row ledger line data #################
1342-
1343+
1344 if line.get('ldate'):
1345 c_specs = [
1346 ('ldate', 1, 0, 'date', datetime.strptime(line['ldate'],'%Y-%m-%d'), None, ll_cell_style_date),
1347@@ -285,79 +287,80 @@
1348 else:
1349 c_specs = [
1350 ('ldate', 1, 0, 'text', None),
1351- ]
1352+ ]
1353 c_specs += [
1354 ('period', 1, 0, 'text', line.get('period_code') or ''),
1355 ('move', 1, 0, 'text', line.get('move_name') or ''),
1356 ('journal', 1, 0, 'text', line.get('jcode') or ''),
1357 ('partner', 1, 0, 'text', line.get('partner_name') or ''),
1358+ ('ref', 1, 0, 'text', line.get('lref') or ''),
1359 ('label', 1, 0, 'text', label),
1360 ('rec_name', 1, 0, 'text', line.get('rec_name') or ''),
1361 ('debit', 1, 0, 'number', line.get('debit'), None, ll_cell_style_decimal),
1362 ('credit', 1, 0, 'number', line.get('credit'), None, ll_cell_style_decimal),
1363 ('cumul_bal', 1, 0, 'number', None, cumbal_formula, ll_cell_style_decimal),
1364- ]
1365+ ]
1366 if _p.amount_currency(data):
1367 c_specs += [
1368 ('curr_bal', 1, 0, 'number', line.get('amount_currency') or 0.0, None, ll_cell_style_decimal),
1369 ('curr_code', 1, 0, 'text', line.get('currency_code') or '', None, ll_cell_style_center),
1370 ]
1371 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
1372- row_pos = self.xls_write_row(ws, row_pos, row_data, ll_cell_style)
1373+ row_pos = self.xls_write_row(ws, row_pos, row_data, ll_cell_style)
1374 #end for line
1375
1376- ################## Print row Cumulated Balance by partner #################
1377- debit_partner_start = rowcol_to_cell(row_start_partner, 7)
1378- debit_partner_end = rowcol_to_cell(row_pos-1, 7)
1379+ ################## Print row Cumulated Balance by partner #################
1380+ debit_partner_start = rowcol_to_cell(row_start_partner, 8)
1381+ debit_partner_end = rowcol_to_cell(row_pos-1, 8)
1382 debit_partner_total = 'SUM(' + debit_partner_start + ':' + debit_partner_end + ')'
1383-
1384- credit_partner_start = rowcol_to_cell(row_start_partner, 8)
1385- credit_partner_end = rowcol_to_cell(row_pos-1, 8)
1386+
1387+ credit_partner_start = rowcol_to_cell(row_start_partner, 9)
1388+ credit_partner_end = rowcol_to_cell(row_pos-1, 9)
1389 credit_partner_total = 'SUM(' + credit_partner_start + ':' + credit_partner_end + ')'
1390-
1391- bal_partner_debit = rowcol_to_cell(row_pos, 7)
1392- bal_partner_credit = rowcol_to_cell(row_pos, 8)
1393- bal_partner_total = bal_partner_debit + '-' + bal_partner_credit
1394-
1395- c_specs = [('empty%s' %x, 1, 0, 'text', None) for x in range(5)]
1396+
1397+ bal_partner_debit = rowcol_to_cell(row_pos, 8)
1398+ bal_partner_credit = rowcol_to_cell(row_pos, 9)
1399+ bal_partner_total = bal_partner_debit + '-' + bal_partner_credit
1400+
1401+ c_specs = [('empty%s' %x, 1, 0, 'text', None) for x in range(6)]
1402 c_specs += [
1403 ('init_bal', 1, 0, 'text', _('Cumulated balance on Partner')),
1404 ('rec', 1, 0, 'text', None),
1405- ('debit', 1, 0, 'number', None, debit_partner_total, c_cumul_cell_style_decimal),
1406- ('credit', 1, 0, 'number', None, credit_partner_total, c_cumul_cell_style_decimal),
1407- ('cumul_bal', 1, 0, 'number', None, bal_partner_total, c_cumul_cell_style_decimal),
1408- ]
1409+ ('debit', 1, 0, 'number', None, debit_partner_total, c_cumul_cell_style_decimal),
1410+ ('credit', 1, 0, 'number', None, credit_partner_total, c_cumul_cell_style_decimal),
1411+ ('cumul_bal', 1, 0, 'number', None, bal_partner_total, c_cumul_cell_style_decimal),
1412+ ]
1413 if _p.amount_currency(data):
1414 if account.currency_id:
1415 c_specs += [('curr_bal', 1, 0, 'number', cumul_balance_curr or 0.0, None, c_cumul_cell_style_decimal)]
1416 else:
1417 c_specs += [('curr_bal', 1, 0, 'text', '-', None, c_cumul_cell_style_right)]
1418- c_specs += [('curr_code', 1, 0, 'text', account.currency_id.name if account.currency_id else u'', None, c_cumul_cell_style_center)]
1419+ c_specs += [('curr_code', 1, 0, 'text', account.currency_id.name if account.currency_id else u'', None, c_cumul_cell_style_center)]
1420 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
1421 row_pos = self.xls_write_row(ws, row_pos, row_data, c_cumul_cell_style)
1422- row_pos += 1
1423+ row_pos += 1
1424 account_total_debit += total_debit
1425 account_total_credit += total_credit
1426 account_balance_cumul += cumul_balance
1427- account_balance_cumul_curr += cumul_balance_curr
1428-
1429- ################## Print row Cumulated Balance by account #################
1430- c_specs = [('acc_title', 5, 0, 'text', ' - '.join([account.code, account.name])), ]
1431+ account_balance_cumul_curr += cumul_balance_curr
1432+
1433+ ################## Print row Cumulated Balance by account #################
1434+ c_specs = [('acc_title', 6, 0, 'text', ' - '.join([account.code, account.name])), ]
1435 c_specs += [
1436 ('label', 1, 0, 'text', _('Cumulated balance on Account')),
1437 ('rec', 1, 0, 'text', None),
1438 ('debit', 1, 0, 'number', account_total_debit, None, account_cell_style_decimal),
1439 ('credit', 1, 0, 'number', account_total_credit, None, account_cell_style_decimal),
1440- ('cumul_bal', 1, 0, 'number', account_balance_cumul, None, account_cell_style_decimal),
1441- ]
1442+ ('cumul_bal', 1, 0, 'number', account_balance_cumul, None, account_cell_style_decimal),
1443+ ]
1444 if _p.amount_currency(data):
1445 if account.currency_id:
1446 c_specs += [('curr_bal', 1, 0, 'number', account_balance_cumul_curr or 0.0, None, account_cell_style_decimal)]
1447 else:
1448 c_specs += [('curr_bal', 1, 0, 'text', '-', None, account_cell_style_right)]
1449- c_specs += [('curr_code', 1, 0, 'text', account.currency_id.name if account.currency_id else u'', None, account_cell_style)]
1450+ c_specs += [('curr_code', 1, 0, 'text', account.currency_id.name if account.currency_id else u'', None, account_cell_style)]
1451 row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
1452- row_pos = self.xls_write_row(ws, row_pos, row_data, account_cell_style)
1453+ row_pos = self.xls_write_row(ws, row_pos, row_data, account_cell_style)
1454 row_pos += 2
1455
1456 partner_ledger_xls('report.account.account_report_partner_ledger_xls', 'account.account',