From 7b5e2b0beba8e75d0c58a7f7939762c00a620e81 Mon Sep 17 00:00:00 2001 From: Anthony Muschang Date: Wed, 15 Oct 2014 18:06:07 +0200 Subject: [PATCH] [CHG]account_financial_report_webkit_xls: Migration to v8 --- .../__openerp__.py | 2 +- .../report/general_ledger_xls.py | 21 +++++++++-------- .../report/open_invoices_xls.py | 15 ++++++++---- .../report/partner_ledger_xls.py | 23 +++++++++++-------- .../report/trial_balance_xls.py | 6 +++-- 5 files changed, 39 insertions(+), 28 deletions(-) diff --git a/account_financial_report_webkit_xls/__openerp__.py b/account_financial_report_webkit_xls/__openerp__.py index 9b8b5b5f..6c2235b3 100644 --- a/account_financial_report_webkit_xls/__openerp__.py +++ b/account_financial_report_webkit_xls/__openerp__.py @@ -45,5 +45,5 @@ 'wizard/open_invoices_wizard_view.xml', ], 'active': False, - 'installable': False, + 'installable': True, } diff --git a/account_financial_report_webkit_xls/report/general_ledger_xls.py b/account_financial_report_webkit_xls/report/general_ledger_xls.py index 15212504..99ba69e4 100644 --- a/account_financial_report_webkit_xls/report/general_ledger_xls.py +++ b/account_financial_report_webkit_xls/report/general_ledger_xls.py @@ -197,11 +197,12 @@ class general_ledger_xls(report_xls): cnt = 0 for account in objects: - display_initial_balance = account.init_balance and \ - (account.init_balance.get( - 'debit', 0.0) != 0.0 or account. - init_balance.get('credit', 0.0) != 0.0) - display_ledger_lines = account.ledger_lines + display_initial_balance = _p['init_balance'][account.id] and \ + (_p['init_balance'][account.id].get( + 'debit', 0.0) != 0.0 or + _p['init_balance'][account.id].get('credit', 0.0) + != 0.0) + display_ledger_lines = _p['ledger_lines'][account.id] if _p.display_account_raw(data) == 'all' or \ (display_ledger_lines or display_initial_balance): @@ -223,11 +224,11 @@ class general_ledger_xls(report_xls): row_start = row_pos if display_initial_balance: - cumul_debit = account.init_balance.get('debit') or 0.0 - cumul_credit = account.init_balance.get('credit') or 0.0 - cumul_balance = account.init_balance.get( - 'init_balance') or 0.0 - cumul_balance_curr = account.init_balance.get( + init_balance = _p['init_balance'][account.id] + cumul_debit = init_balance.get('debit') or 0.0 + cumul_credit = init_balance.get('credit') or 0.0 + cumul_balance = init_balance.get('init_balance') or 0.0 + cumul_balance_curr = init_balance.get( 'init_balance_currency') or 0.0 c_specs = [('empty%s' % x, 1, 0, 'text', None) for x in range(6)] diff --git a/account_financial_report_webkit_xls/report/open_invoices_xls.py b/account_financial_report_webkit_xls/report/open_invoices_xls.py index 66aec829..7f2b3e18 100644 --- a/account_financial_report_webkit_xls/report/open_invoices_xls.py +++ b/account_financial_report_webkit_xls/report/open_invoices_xls.py @@ -725,10 +725,12 @@ class open_invoices_xls(report_xls): # selected def print_grouped_line_report(self, row_pos, account, _xs, xlwt, _p, data): - if account.grouped_ledger_lines and account.partners_order: + if account.grouped_ledger_lines and \ + _p['partners_order'][account.id]: row_start_account = row_pos - for partner_name, p_id, p_ref, p_name in account.partners_order: + for partner_name, p_id, p_ref, p_name \ + in _p['partners_order'][account.id]: row_pos = self.print_row_code_account( "regroup", account, row_pos, partner_name) @@ -757,13 +759,16 @@ class open_invoices_xls(report_xls): # export the invoice AR/AP lines def print_ledger_lines(self, row_pos, account, _xs, xlwt, _p, data): - if account.ledger_lines and account.partners_order: + if _p['ledger_lines'][account.id] \ + and _p['partners_order'][account.id]: + row_start_account = row_pos # Print account line: code - account row_pos = self.print_row_code_account( "noregroup", account, row_pos, "") - for partner_name, p_id, p_ref, p_name in account.partners_order: + for partner_name, p_id, p_ref, p_name \ + in _p['partners_order'][account.id]: # Print partner row row_pos = self.print_row_partner(row_pos, partner_name) @@ -773,7 +778,7 @@ class open_invoices_xls(report_xls): row_pos_start = row_pos line_number = 0 - for line in account.ledger_lines.get(p_id, []): + for line in _p['ledger_lines'][account.id].get(p_id, []): line_number += 1 # print ledger lines row_pos = self.print_lines( diff --git a/account_financial_report_webkit_xls/report/partner_ledger_xls.py b/account_financial_report_webkit_xls/report/partner_ledger_xls.py index e8e4a4e1..65983ca2 100644 --- a/account_financial_report_webkit_xls/report/partner_ledger_xls.py +++ b/account_financial_report_webkit_xls/report/partner_ledger_xls.py @@ -214,7 +214,7 @@ class partner_ledger_xls(report_xls): cnt = 0 for account in objects: - if account.ledger_lines or account.init_balance: + if _p['ledger_lines'].get(account.id, False) or _p['init_balance'].get(account.id, False): if not account.partners_order: continue cnt += 1 @@ -254,9 +254,9 @@ class partner_ledger_xls(report_xls): row_pos = self.xls_write_row(ws, row_pos, c_hdr_data) row_start_partner = row_pos - total_debit = account.init_balance.get( + total_debit = _p['init_balance'][account.id].get( p_id, {}).get('debit') or 0.0 - total_credit = account.init_balance.get( + total_credit = _p['init_balance'][account.id].get( p_id, {}).get('credit') or 0.0 init_line = False @@ -264,12 +264,15 @@ class partner_ledger_xls(report_xls): (total_debit or total_credit): init_line = True - part_cumul_balance = account.init_balance.get( - p_id, {}).get('init_balance') or 0.0 - part_cumul_balance_curr = account.init_balance.get( - p_id, {}).get('init_balance_currency') or 0.0 - balance_forward_currency = account.init_balance.get( - p_id, {}).get('currency_name') or '' + part_cumul_balance = \ + _p['init_balance'][account.id].get( + p_id, {}).get('init_balance') or 0.0 + part_cumul_balance_curr = \ + _p['init_balance'][account.id].get( + p_id, {}).get('init_balance_currency') or 0.0 + balance_forward_currency = \ + _p['init_balance'][account.id].get( + p_id, {}).get('currency_name') or '' cumul_balance += part_cumul_balance cumul_balance_curr += part_cumul_balance_curr @@ -304,7 +307,7 @@ class partner_ledger_xls(report_xls): row_pos = self.xls_write_row( ws, row_pos, row_data, c_init_cell_style) - for line in account.ledger_lines.get(p_id, []): + for line in _p['ledger_lines'][account.id].get(p_id, []): total_debit += line.get('debit') or 0.0 total_credit += line.get('credit') or 0.0 diff --git a/account_financial_report_webkit_xls/report/trial_balance_xls.py b/account_financial_report_webkit_xls/report/trial_balance_xls.py index ec479f4f..438935fa 100644 --- a/account_financial_report_webkit_xls/report/trial_balance_xls.py +++ b/account_financial_report_webkit_xls/report/trial_balance_xls.py @@ -237,7 +237,7 @@ class trial_balance_xls(report_xls): for current_account in objects: - if not current_account.to_display: + if not _p['to_display_accounts'][current_account.id]: continue if current_account.type == 'view': @@ -277,7 +277,9 @@ class trial_balance_xls(report_xls): bal_formula = init_cell + '+' + \ debit_cell + '-' + credit_cell c_specs += [('init_bal', 1, 0, 'number', - current_account.init_balance, None, + _p['init_balance_' + 'accounts'][current_account.id], + None, cell_style_decimal)] c_specs += [ ('debit', 1, 0, 'number', current_account.debit,