From cc80f66f56bd9bfeb7c45d07ad901866c66fca08 Mon Sep 17 00:00:00 2001 From: "Adrien Peiffer (ACSONE)" Date: Fri, 5 Feb 2016 18:42:55 +0100 Subject: [PATCH] [FIX] Flake8 issues --- .../report/aged_partner_balance.py | 12 ++++--- .../report/common_partner_balance_reports.py | 5 ++- .../report/common_reports.py | 7 ++-- .../report/open_invoices.py | 4 +-- .../report/partners_ledger.py | 4 +-- .../report/webkit_parser_header_fix.py | 5 +-- .../report/general_ledger_xls.py | 3 +- .../report/open_invoices_xls.py | 34 ++++++++++--------- .../report/partners_balance_xls.py | 8 +++-- .../report/trial_balance_xls.py | 5 +-- .../report/nov_account_journal.py | 18 +++++----- mis_builder/static/src/xml/mis_widget.xml | 2 +- 12 files changed, 59 insertions(+), 48 deletions(-) diff --git a/account_financial_report_webkit/report/aged_partner_balance.py b/account_financial_report_webkit/report/aged_partner_balance.py index fd9cb550..9275af2f 100644 --- a/account_financial_report_webkit/report/aged_partner_balance.py +++ b/account_financial_report_webkit/report/aged_partner_balance.py @@ -285,10 +285,14 @@ class AccountAgedTrialBalanceWebkit(PartnersOpenInvoicesWebkit): :returns: delta in days """ - sale_lines = [x for x in ledger_lines if x['jtype'] in REC_PAY_TYPE - and line['rec_id'] == x['rec_id']] - refund_lines = [x for x in ledger_lines if x['jtype'] in REFUND_TYPE - and line['rec_id'] == x['rec_id']] + sale_lines = [ + x for x in ledger_lines if x['jtype'] in REC_PAY_TYPE and + line['rec_id'] == x['rec_id'] + ] + refund_lines = [ + x for x in ledger_lines if x['jtype'] in REFUND_TYPE and + line['rec_id'] == x['rec_id'] + ] if len(sale_lines) == 1: reference_line = sale_lines[0] elif len(refund_lines) == 1: diff --git a/account_financial_report_webkit/report/common_partner_balance_reports.py b/account_financial_report_webkit/report/common_partner_balance_reports.py index b291a8bf..87755388 100644 --- a/account_financial_report_webkit/report/common_partner_balance_reports.py +++ b/account_financial_report_webkit/report/common_partner_balance_reports.py @@ -312,7 +312,10 @@ class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit, for partner_id, partner_values in \ values['partners_amounts'].copy().iteritems(): - base_partner_balance = partners_amounts_accounts[account.id][partner_id]['balance']\ + partners_amounts_account =\ + partners_amounts_accounts[account.id] + base_partner_balance =\ + partners_amounts_account[partner_id]['balance']\ if partners_amounts_accounts.get(account.id)\ and partners_amounts_accounts.get(account.id)\ .get(partner_id) else 0.0 diff --git a/account_financial_report_webkit/report/common_reports.py b/account_financial_report_webkit/report/common_reports.py index 11c4203d..cd7af7eb 100644 --- a/account_financial_report_webkit/report/common_reports.py +++ b/account_financial_report_webkit/report/common_reports.py @@ -130,9 +130,10 @@ class CommonReportHeaderWebkit(common_report_header): def recursive_sort_by_code(accounts, parent): sorted_accounts = [] # add all accounts with same parent - level_accounts = [account for account in accounts - if account['parent_id'] - and account['parent_id'][0] == parent['id']] + level_accounts = [ + account for account in accounts + if account['parent_id'] and + account['parent_id'][0] == parent['id']] # add consolidation children of parent, as they are logically on # the same level if parent.get('child_consol_ids'): diff --git a/account_financial_report_webkit/report/open_invoices.py b/account_financial_report_webkit/report/open_invoices.py index 3afdd099..158acf85 100644 --- a/account_financial_report_webkit/report/open_invoices.py +++ b/account_financial_report_webkit/report/open_invoices.py @@ -164,8 +164,8 @@ class PartnersOpenInvoicesWebkit(report_sxw.rml_parse, non_null_init_balances = dict([ (ib, amounts) for ib, amounts in init_balance[account.id].iteritems() - if amounts['init_balance'] - or amounts['init_balance_currency']]) + if amounts['init_balance'] or + amounts['init_balance_currency']]) init_bal_lines_pids = non_null_init_balances.keys() partners_order[account.id] = self._order_partners( diff --git a/account_financial_report_webkit/report/partners_ledger.py b/account_financial_report_webkit/report/partners_ledger.py index df66efac..dc0eeed6 100644 --- a/account_financial_report_webkit/report/partners_ledger.py +++ b/account_financial_report_webkit/report/partners_ledger.py @@ -165,8 +165,8 @@ class PartnersLedgerWebkit(report_sxw.rml_parse, non_null_init_balances = dict( [(ib, amounts) for ib, amounts in init_balance[account.id].iteritems() - if amounts['init_balance'] - or amounts['init_balance_currency']]) + if amounts['init_balance'] or + amounts['init_balance_currency']]) init_bal_lines_pids = non_null_init_balances.keys() else: init_balance[account.id] = {} diff --git a/account_financial_report_webkit/report/webkit_parser_header_fix.py b/account_financial_report_webkit/report/webkit_parser_header_fix.py index a92c90fa..9484aaf0 100644 --- a/account_financial_report_webkit/report/webkit_parser_header_fix.py +++ b/account_financial_report_webkit/report/webkit_parser_header_fix.py @@ -27,6 +27,9 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## +from mako.template import Template +from mako.lookup import TemplateLookup + import os import subprocess import tempfile @@ -75,8 +78,6 @@ _logger = logging.getLogger('financial.reports.webkit') # redefine mako_template as this is overriden by jinja since saas-1 # from openerp.addons.report_webkit.webkit_report import mako_template -from mako.template import Template -from mako.lookup import TemplateLookup def mako_template(text): 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 401ba3b7..52a3d759 100644 --- a/account_financial_report_webkit_xls/report/general_ledger_xls.py +++ b/account_financial_report_webkit_xls/report/general_ledger_xls.py @@ -200,8 +200,7 @@ class general_ledger_xls(report_xls): 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) + _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 \ 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 5180c658..08d2135e 100644 --- a/account_financial_report_webkit_xls/report/open_invoices_xls.py +++ b/account_financial_report_webkit_xls/report/open_invoices_xls.py @@ -260,8 +260,9 @@ class open_invoices_xls(report_xls): partner_name): if regroupmode == "regroup": c_specs = [('acc_title', self.nbr_columns, 0, 'text', - ' - '.join([account.code, account.name, partner_name - or _('No partner')])), ] + ' - '.join([account.code, + account.name, + partner_name or _('No partner')])), ] else: c_specs = [ ('acc_title', self.nbr_columns, 0, 'text', ' - '. @@ -332,10 +333,10 @@ class open_invoices_xls(report_xls): else: c_specs += [('datedue', 1, 0, 'text', None)] c_specs += [ - ('debit', 1, 0, 'number', line.get('debit') - or 0.0, None, style_line_decimal), - ('credit', 1, 0, 'number', line.get('credit') - or 0.0, None, style_line_decimal), + ('debit', 1, 0, 'number', line.get('debit') or 0.0, None, + style_line_decimal), + ('credit', 1, 0, 'number', line.get('credit') or 0.0, None, + style_line_decimal), ] # determine the formula of the cumulated balance @@ -357,8 +358,9 @@ class open_invoices_xls(report_xls): if _p.amount_currency(data): if account.currency_id: c_specs += [ - ('curramount', 1, 0, 'number', line.get('amount_currency') - or 0.0, None, style_line_decimal), + ('curramount', 1, 0, 'number', + line.get('amount_currency') or 0.0, None, + style_line_decimal), ('currcode', 1, 0, 'text', line[ 'currency_code'], None, style_line_right), ] @@ -428,18 +430,18 @@ class open_invoices_xls(report_xls): else: c_specs += [('datedue', 1, 0, 'text', None)] c_specs += [ - ('debit', 1, 0, 'number', line.get('debit') - or 0.0, None, style_line_decimal), - ('credit', 1, 0, 'number', line.get('credit') - or 0.0, None, style_line_decimal), + ('debit', 1, 0, 'number', line.get('debit') or 0.0, None, + style_line_decimal), + ('credit', 1, 0, 'number', line.get('credit') or 0.0, None, + style_line_decimal), ('cumul', 1, 0, 'number', None, cumul_balance, style_line_decimal), ] if account.currency_id: c_specs += [ - ('curramount', 1, 0, 'number', line.get('amount_currency') - or 0.0, None, style_line_decimal), - ('currcode', 1, 0, 'text', line.get('currency_code') - or '', None, style_line_right), + ('curramount', 1, 0, 'number', + line.get('amount_currency') or 0.0, None, style_line_decimal), + ('currcode', 1, 0, 'text', + line.get('currency_code') or '', None, style_line_right), ] else: c_specs += [ diff --git a/account_financial_report_webkit_xls/report/partners_balance_xls.py b/account_financial_report_webkit_xls/report/partners_balance_xls.py index 7c16af9c..9255b567 100644 --- a/account_financial_report_webkit_xls/report/partners_balance_xls.py +++ b/account_financial_report_webkit_xls/report/partners_balance_xls.py @@ -137,9 +137,11 @@ class partners_balance_xls(report_xls): ('c', 2, 0, 'text', _('Comparison') + str(index + 1) + ' (C' + str(index + 1) + ')')] if params['comparison_filter'] == 'filter_date': - c_specs += [('f', 2, 0, 'text', _('Dates Filter') + ': ' + - _p.formatLang(params['start'], date=True) + ' - ' - + _p.formatLang(params['stop'], date=True))] + c_specs += [ + ('f', 2, 0, 'text', + _('Dates Filter') + ': ' + + _p.formatLang(params['start'], date=True) + ' - ' + + _p.formatLang(params['stop'], date=True))] elif params['comparison_filter'] == 'filter_period': c_specs += [('f', 2, 0, 'text', _('Periods Filter') + ': ' + params['start'].name + ' - ' + 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 b82fba80..476375a0 100644 --- a/account_financial_report_webkit_xls/report/trial_balance_xls.py +++ b/account_financial_report_webkit_xls/report/trial_balance_xls.py @@ -308,8 +308,9 @@ class trial_balance_xls(report_xls): ('diff', 1, 0, 'number', comp_account[ 'diff'], None, cell_style_decimal), ('diff_percent', 1, 0, 'number', comp_account[ - 'percent_diff'] and comp_account['percent_diff'] - or 0, None, cell_style_pct), + 'percent_diff'] and + comp_account['percent_diff'] or 0, None, + cell_style_pct), ] c_specs += [('type', 1, 0, 'text', diff --git a/account_journal_report_xls/report/nov_account_journal.py b/account_journal_report_xls/report/nov_account_journal.py index 2b0278c3..f400d14e 100644 --- a/account_journal_report_xls/report/nov_account_journal.py +++ b/account_journal_report_xls/report/nov_account_journal.py @@ -166,8 +166,8 @@ class nov_journal_print(report_sxw.rml_parse): "rc.symbol AS currency_symbol, " "coalesce(ai.internal_number,'-') AS inv_number, " "coalesce(abs.name,'-') AS st_number, " - "coalesce(av.number,'-') AS voucher_number " - + select_extra + + "coalesce(av.number,'-') AS voucher_number " + + select_extra + "FROM account_move_line l " "INNER JOIN account_move am ON l.move_id = am.id " "INNER JOIN account_account aa " @@ -192,11 +192,9 @@ class nov_journal_print(report_sxw.rml_parse): "LEFT OUTER JOIN account_analytic_account ana " "ON l.analytic_account_id = ana.id " "LEFT OUTER JOIN res_currency rc " - "ON l.currency_id = rc.id " - + join_extra + + "ON l.currency_id = rc.id " + join_extra + "WHERE l.period_id IN %s AND l.journal_id = %s " - "AND am.state IN %s " - + where_extra + + "AND am.state IN %s " + where_extra + "ORDER BY " + self.sort_selection + ", move_date, move_id, acc_code", (tuple(period_ids), journal_id, @@ -206,12 +204,12 @@ class nov_journal_print(report_sxw.rml_parse): # add reference of corresponding origin document if journal.type in ('sale', 'sale_refund', 'purchase', 'purchase_refund'): - [x.update({'docname': (_('Invoice') + ': ' + x['inv_number']) - or (_('Voucher') + ': ' + x['voucher_number']) or '-'}) + [x.update({'docname': (_('Invoice') + ': ' + x['inv_number']) or + (_('Voucher') + ': ' + x['voucher_number']) or '-'}) for x in lines] elif journal.type in ('bank', 'cash'): - [x.update({'docname': (_('Statement') + ': ' + x['st_number']) - or (_('Voucher') + ': ' + x['voucher_number']) or '-'}) + [x.update({'docname': (_('Statement') + ': ' + x['st_number']) or + (_('Voucher') + ': ' + x['voucher_number']) or '-'}) for x in lines] else: code_string = j_obj._report_xls_document_extra( diff --git a/mis_builder/static/src/xml/mis_widget.xml b/mis_builder/static/src/xml/mis_widget.xml index 5cfd9994..9b922e61 100644 --- a/mis_builder/static/src/xml/mis_widget.xml +++ b/mis_builder/static/src/xml/mis_widget.xml @@ -42,7 +42,7 @@ - +