421
425
report_sxw.report_sxw('report.account.general.ledger_landscape', 'account.account', 'addons/account/report/general_ledger_landscape.rml', parser=general_ledger_landscape, header=False)
427
class general_ledger_report_xls(report_xls):
429
def generate_xls_report(self, parser, data, obj, wb):
430
"""Generate report inside XLS WorkBook
431
@parser: instance of report_sxw.rml_parse
432
@data: wizard form data
433
@obj: object on which we're going to do the reporting
434
@wb: instance of xlwt.WorkBook
437
# 0: We create a new WorkSheet
438
c = parser.localcontext['company']
439
ws = wb.add_sheet(('General Ledger - %s' % (c.partner_id.ref))[:31])
441
# 1: We set some worksheet properties
442
ws.panes_frozen = True
443
ws.remove_splits = True
444
ws.portrait = 0 # Landscape
445
ws.fit_width_to_pages = 1
447
# 2: We define columns:
448
# ('Field Name', COLSPAN, COLUMN_SIZE, TYPE,
452
# def get_data_function(x, d, p):
455
# @d: wizard data form
456
# @p: instance of report_sxw.rml_parse
459
('Create Date', 12, 0, 'text',
460
lambda x, d, p: 'Create date: ' + p.formatLang(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),date_time = True)),
462
('Account', 8, 0, 'text',
463
lambda x, d, p: '%s %s' % (x.code, x.name)),
464
('Account Debit', 1, 0, 'number',
465
lambda x, d, p: p._sum_debit_account(x, d['form'])),
466
('Account Credit', 1, 0, 'number',
467
lambda x, d, p: p._sum_credit_account(x, d['form'])),
468
('Account Balance', 1, 0, 'number',
469
lambda x, d, p: p._sum_solde_account(x, d['form'])),
470
('Account Currency', 1, 0, 'text',
471
lambda x, d, p: str(p._sum_currency_amount_account(x, d['form']))),
473
('Date', 1, 66, 'text',
474
lambda x, d, p: p.formatLang(x['date'],date=True)),
475
('JNRL', 1, 35, 'text',
476
lambda x, d, p: x['code']),
477
('Partner', 1, 150, 'text',
478
lambda x, d, p: x['partner']),
479
('Ref', 1, 90, 'text',
480
lambda x, d, p: x['ref']),
481
('Mvt', 1, 60, 'text',
482
lambda x, d, p: x['move']),
483
('Reconcile', 1, 60, 'text',
484
lambda x, d, p: x['reconcile_name']),
485
('Entry Label', 1, 335, 'text',
486
lambda x, d, p: x['name']),
487
('Couterpart', 1, 50, 'text',
488
lambda x, d, p: x['line_corresp'][:15]),
489
('Debit', 1, 70, 'number',
490
lambda x, d, p: x['debit']),
491
('Credit', 1, 70, 'number',
492
lambda x, d, p: x['credit']),
493
('Balance', 1, 70, 'number',
494
lambda x, d, p: x['progress']),
495
('Currency', 1, 70, 'text',
496
lambda x, d, p: str(x['amount_currency'] or 0.0)),
499
# 3: Define rows templates
500
hdr_acct = ['Account','Account Debit','Account Credit','Account Balance']
501
hdr_acct_line = ['Date','JNRL','Partner','Ref','Mvt','Reconcile','Entry Label','Couterpart','Debit','Credit','Balance']
503
if data.get('form',{}).get('currency',True):
504
hdr_acct.append('Account Currency')
505
hdr_acct_line.append('Currency')
507
row_hdr = self.xls_row_template(cols_specs, ['Create Date'])
508
row_acct = self.xls_row_template(cols_specs, hdr_acct)
509
row_acct_line = self.xls_row_template(cols_specs, hdr_acct_line)
512
row_hdr_style = xlwt.easyxf(
513
'pattern: pattern solid, fore_color gray25;'
515
row_acct_style = xlwt.easyxf(
517
'borders: bottom thin;'
519
row_acct_line_style = xlwt.easyxf()
521
# 5: Write sheet header
522
self.xls_write_row(ws, None, data, parser,
523
0, row_hdr, row_hdr_style)
524
self.xls_write_row_header(ws, 1, row_acct, row_hdr_style)
525
self.xls_write_row_header(ws, 2, row_acct_line, row_hdr_style, set_column_size=True)
527
# 6: Freeze sheet header
529
ws.horz_split_pos = row_count
531
# 7: Loop for each lines (depends on report)
532
for o in parser.get_children_accounts(obj, data['form']):
533
# Display account summary
534
r = ws.row(row_count)
535
self.xls_write_row(ws, o, data, parser,
536
row_count, row_acct, row_acct_style)
539
# Display each move line per account
540
for l in parser.lines(o, data['form']):
541
self.xls_write_row(ws, l, data, parser,
542
row_count, row_acct_line, row_acct_line_style)
545
general_ledger_report_xls('report.account.general.ledger.xls',
547
'addons/account/report/general_ledger_landscape.rml',
548
parser=general_ledger_landscape,
422
550
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: