Merge pull request #253 from Noviat/8.0-fix-webkit-reports

[MERGE] pep8 and context propagation #253
pull/260/head
Stéphane Bidoul (ACSONE) 2016-12-30 13:59:23 +01:00 committed by GitHub
commit 8af139631a
21 changed files with 54 additions and 203 deletions

View File

@ -99,7 +99,7 @@ like the trial balance but add an extra information :
* Total balance (all figures must match with same date partner balance * Total balance (all figures must match with same date partner balance
report). report).
This column equals the sum of all following columns) This column equals the sum of all following columns)
* Due * Due
* Overdue <= 30 days * Overdue <= 30 days

View File

@ -45,6 +45,7 @@ def make_ranges(top, offset):
ranges.append((top, 100000000000)) ranges.append((top, 100000000000))
return ranges return ranges
# list of overdue ranges # list of overdue ranges
RANGES = make_ranges(120, 30) RANGES = make_ranges(120, 30)
@ -56,6 +57,7 @@ def make_ranges_titles():
titles.append(_('Overdue > %s d.') % RANGES[-1][0]) titles.append(_('Overdue > %s d.') % RANGES[-1][0])
return titles return titles
# list of overdue ranges title # list of overdue ranges title
RANGES_TITLES = make_ranges_titles() RANGES_TITLES = make_ranges_titles()
# list of payable journal types # list of payable journal types
@ -408,6 +410,7 @@ class AccountAgedOpenInvoicesWebkit(PartnersOpenInvoicesWebkit):
res = self.cr.fetchall() res = self.cr.fetchall()
return dict((x[0], x[1]) for x in res) return dict((x[0], x[1]) for x in res)
HeaderFooterTextWebKitParser( HeaderFooterTextWebKitParser(
'report.account.account_aged_open_invoices_webkit', 'report.account.account_aged_open_invoices_webkit',
'account.account', 'account.account',

View File

@ -43,6 +43,7 @@ def make_ranges(top, offset):
ranges.append((top, 100000000000)) ranges.append((top, 100000000000))
return ranges return ranges
# list of overdue ranges # list of overdue ranges
RANGES = make_ranges(120, 30) RANGES = make_ranges(120, 30)
@ -54,6 +55,7 @@ def make_ranges_titles():
titles.append(_('Overdue > %s d.') % RANGES[-1][0]) titles.append(_('Overdue > %s d.') % RANGES[-1][0])
return titles return titles
# list of overdue ranges title # list of overdue ranges title
RANGES_TITLES = make_ranges_titles() RANGES_TITLES = make_ranges_titles()
# list of payable journal types # list of payable journal types
@ -420,6 +422,7 @@ class AccountAgedTrialBalanceWebkit(PartnersOpenInvoicesWebkit):
res = self.cr.fetchall() res = self.cr.fetchall()
return dict((x[0], x[1]) for x in res) return dict((x[0], x[1]) for x in res)
HeaderFooterTextWebKitParser( HeaderFooterTextWebKitParser(
'report.account.account_aged_trial_balance_webkit', 'report.account.account_aged_trial_balance_webkit',
'account.account', 'account.account',

View File

@ -40,6 +40,7 @@ def get_mako_template(obj, *args):
template_path = get_module_resource(*args) template_path = get_module_resource(*args)
return Template(filename=template_path, input_encoding='utf-8') return Template(filename=template_path, input_encoding='utf-8')
report_helper.WebKitHelper.get_mako_template = get_mako_template report_helper.WebKitHelper.get_mako_template = get_mako_template

View File

@ -93,6 +93,7 @@ class PartnerBalanceWebkit(report_sxw.rml_parse,
return super(PartnerBalanceWebkit, self).set_context( return super(PartnerBalanceWebkit, self).set_context(
objects, data, new_ids, report_type=report_type) objects, data, new_ids, report_type=report_type)
HeaderFooterTextWebKitParser( HeaderFooterTextWebKitParser(
'report.account.account_report_partner_balance_webkit', 'report.account.account_report_partner_balance_webkit',
'account.account', 'account.account',

View File

@ -158,6 +158,7 @@ class PrintJournalWebkit(report_sxw.rml_parse, CommonReportHeaderWebkit):
return super(PrintJournalWebkit, self).set_context( return super(PrintJournalWebkit, self).set_context(
objects, data, new_ids, report_type=report_type) objects, data, new_ids, report_type=report_type)
HeaderFooterTextWebKitParser( HeaderFooterTextWebKitParser(
'report.account.account_report_print_journal_webkit', 'report.account.account_report_print_journal_webkit',
'account.journal.period', 'account.journal.period',

View File

@ -85,6 +85,7 @@ class TrialBalanceWebkit(report_sxw.rml_parse,
return super(TrialBalanceWebkit, self).set_context( return super(TrialBalanceWebkit, self).set_context(
objects, data, new_ids, report_type=report_type) objects, data, new_ids, report_type=report_type)
HeaderFooterTextWebKitParser( HeaderFooterTextWebKitParser(
'report.account.account_report_trial_balance_webkit', 'report.account.account_report_trial_balance_webkit',
'account.account', 'account.account',

View File

@ -392,7 +392,7 @@ class AccountBalanceCommonWizard(orm.TransientModel):
def pre_print_report(self, cr, uid, ids, data, context=None): def pre_print_report(self, cr, uid, ids, data, context=None):
data = super(AccountBalanceCommonWizard, self).pre_print_report( data = super(AccountBalanceCommonWizard, self).pre_print_report(
cr, uid, ids, data, context) cr, uid, ids, data, context=context)
if context is None: if context is None:
context = {} context = {}

View File

@ -78,7 +78,7 @@ class AccountReportGeneralLedgerWizard(orm.TransientModel):
def pre_print_report(self, cr, uid, ids, data, context=None): def pre_print_report(self, cr, uid, ids, data, context=None):
data = super(AccountReportGeneralLedgerWizard, self).pre_print_report( data = super(AccountReportGeneralLedgerWizard, self).pre_print_report(
cr, uid, ids, data, context) cr, uid, ids, data, context=context)
# will be used to attach the report on the main account # will be used to attach the report on the main account
data['ids'] = [data['form']['chart_account_id']] data['ids'] = [data['form']['chart_account_id']]
vals = self.read(cr, uid, ids, vals = self.read(cr, uid, ids,

View File

@ -133,7 +133,7 @@ are still unpaid today (today is my clearance date)?'
def pre_print_report(self, cr, uid, ids, data, context=None): def pre_print_report(self, cr, uid, ids, data, context=None):
data = super(AccountReportOpenInvoicesWizard, self).pre_print_report( data = super(AccountReportOpenInvoicesWizard, self).pre_print_report(
cr, uid, ids, data, context) cr, uid, ids, data, context=context)
vals = self.read(cr, uid, ids, vals = self.read(cr, uid, ids,
['until_date', 'group_by_currency'], ['until_date', 'group_by_currency'],
context=context)[0] context=context)[0]

View File

@ -121,7 +121,7 @@ class AccountReportPartnersLedgerWizard(orm.TransientModel):
def pre_print_report(self, cr, uid, ids, data, context=None): def pre_print_report(self, cr, uid, ids, data, context=None):
data = super(AccountReportPartnersLedgerWizard, self).pre_print_report( data = super(AccountReportPartnersLedgerWizard, self).pre_print_report(
cr, uid, ids, data, context) cr, uid, ids, data, context=context)
if context is None: if context is None:
context = {} context = {}
# will be used to attach the report on the main account # will be used to attach the report on the main account

View File

@ -59,7 +59,7 @@ class AccountReportPrintJournalWizard(orm.TransientModel):
def pre_print_report(self, cr, uid, ids, data, context=None): def pre_print_report(self, cr, uid, ids, data, context=None):
data = super(AccountReportPrintJournalWizard, self).\ data = super(AccountReportPrintJournalWizard, self).\
pre_print_report(cr, uid, ids, data, context) pre_print_report(cr, uid, ids, data, context=context)
# will be used to attach the report on the main account # will be used to attach the report on the main account
data['ids'] = [data['form']['chart_account_id']] data['ids'] = [data['form']['chart_account_id']]
vals = self.read(cr, uid, ids, vals = self.read(cr, uid, ids,

View File

@ -1,25 +1,4 @@
# -*- encoding: utf-8 -*- # -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import general_ledger_xls from . import general_ledger_xls
from . import trial_balance_xls from . import trial_balance_xls
from . import partners_balance_xls from . import partners_balance_xls

View File

@ -1,25 +1,6 @@
# -*- encoding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # Copyright 2009-2016 Noviat
# # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import xlwt import xlwt
from datetime import datetime from datetime import datetime
from openerp.addons.report_xls.report_xls import report_xls from openerp.addons.report_xls.report_xls import report_xls
@ -345,6 +326,7 @@ class general_ledger_xls(report_xls):
ws, row_pos, row_data, c_hdr_cell_style) ws, row_pos, row_data, c_hdr_cell_style)
row_pos += 1 row_pos += 1
general_ledger_xls('report.account.account_report_general_ledger_xls', general_ledger_xls('report.account.account_report_general_ledger_xls',
'account.account', 'account.account',
parser=GeneralLedgerWebkit) parser=GeneralLedgerWebkit)

View File

@ -1,25 +1,6 @@
# -*- encoding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # Copyright 2009-2016 Noviat
# # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import xlwt import xlwt
from datetime import datetime from datetime import datetime
from openerp.addons.report_xls.report_xls import report_xls from openerp.addons.report_xls.report_xls import report_xls
@ -824,5 +805,6 @@ class open_invoices_xls(report_xls):
row_pos, acc, _xs, xlwt, _p, data) row_pos, acc, _xs, xlwt, _p, data)
row_pos += 1 row_pos += 1
open_invoices_xls('report.account.account_report_open_invoices_xls', open_invoices_xls('report.account.account_report_open_invoices_xls',
'account.account', parser=PartnersOpenInvoicesWebkit) 'account.account', parser=PartnersOpenInvoicesWebkit)

View File

@ -1,25 +1,6 @@
# -*- encoding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # Copyright 2009-2016 Noviat
# # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import xlwt import xlwt
from datetime import datetime from datetime import datetime
from openerp.addons.report_xls.report_xls import report_xls from openerp.addons.report_xls.report_xls import report_xls
@ -456,6 +437,7 @@ class partner_ledger_xls(report_xls):
ws, row_pos, row_data, account_cell_style) ws, row_pos, row_data, account_cell_style)
row_pos += 2 row_pos += 2
partner_ledger_xls('report.account.account_report_partner_ledger_xls', partner_ledger_xls('report.account.account_report_partner_ledger_xls',
'account.account', 'account.account',
parser=PartnersLedgerWebkit) parser=PartnersLedgerWebkit)

View File

@ -1,25 +1,6 @@
# -*- encoding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # Copyright 2009-2016 Noviat
# # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import xlwt import xlwt
from openerp.addons.report_xls.report_xls import report_xls from openerp.addons.report_xls.report_xls import report_xls
from openerp.addons.report_xls.utils import rowcol_to_cell from openerp.addons.report_xls.utils import rowcol_to_cell
@ -427,6 +408,7 @@ class partners_balance_xls(report_xls):
row_pos = self.print_account_totals( row_pos = self.print_account_totals(
_xs, xlwt, ws, row_account_start, row_pos, current_account, _p) _xs, xlwt, ws, row_account_start, row_pos, current_account, _p)
partners_balance_xls('report.account.account_report_partner_balance_xls', partners_balance_xls('report.account.account_report_partner_balance_xls',
'account.account', 'account.account',
parser=PartnerBalanceWebkit) parser=PartnerBalanceWebkit)

View File

@ -1,25 +1,6 @@
# -*- encoding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # Copyright 2009-2016 Noviat
# # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import xlwt import xlwt
from openerp.addons.report_xls.report_xls import report_xls from openerp.addons.report_xls.report_xls import report_xls
from openerp.addons.report_xls.utils import rowcol_to_cell from openerp.addons.report_xls.utils import rowcol_to_cell
@ -319,6 +300,7 @@ class trial_balance_xls(report_xls):
row_pos = self.xls_write_row( row_pos = self.xls_write_row(
ws, row_pos, row_data, row_style=cell_style) ws, row_pos, row_data, row_style=cell_style)
trial_balance_xls('report.account.account_report_trial_balance_xls', trial_balance_xls('report.account.account_report_trial_balance_xls',
'account.account', 'account.account',
parser=TrialBalanceWebkit) parser=TrialBalanceWebkit)

View File

@ -1,24 +1,6 @@
# -*- encoding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # Copyright 2009-2016 Noviat
# # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2014 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time import time
from openerp.report import report_sxw from openerp.report import report_sxw
@ -215,7 +197,11 @@ class nov_journal_print(report_sxw.rml_parse):
code_string = j_obj._report_xls_document_extra( code_string = j_obj._report_xls_document_extra(
self.cr, self.uid, self.context) self.cr, self.uid, self.context)
# _logger.warn('code_string= %s', code_string) # _logger.warn('code_string= %s', code_string)
[x.update({'docname': eval(code_string) or '-'}) for x in lines] # disable=W0123, safe_eval doesn't apply here since
# code_string comes from python module
[x.update(
{'docname': eval(code_string) or '-'}) # pylint: disable=W0123
for x in lines]
# group lines # group lines
if self.group_entries: if self.group_entries:
@ -352,6 +338,7 @@ class nov_journal_print(report_sxw.rml_parse):
value, digits, value, digits,
date, date_time, grouping, monetary, dp, currency_obj) date, date_time, grouping, monetary, dp, currency_obj)
report_sxw.report_sxw( report_sxw.report_sxw(
'report.nov.account.journal.print', 'account.journal', 'report.nov.account.journal.print', 'account.journal',
'addons/account_journal_report_xls/report/nov_account_journal.rml', 'addons/account_journal_report_xls/report/nov_account_journal.rml',

View File

@ -1,24 +1,6 @@
# -*- encoding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # Copyright 2009-2016 Noviat
# # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import xlwt import xlwt
from datetime import datetime from datetime import datetime
@ -404,5 +386,6 @@ class account_journal_xls(report_xls):
row_pos = self._journal_lines(o, ws, _p, row_pos, _xs) row_pos = self._journal_lines(o, ws, _p, row_pos, _xs)
row_pos = self._journal_vat_summary(o, ws, _p, row_pos, _xs) row_pos = self._journal_vat_summary(o, ws, _p, row_pos, _xs)
account_journal_xls('report.nov.account.journal.xls', 'account.journal.period', account_journal_xls('report.nov.account.journal.xls', 'account.journal.period',
parser=account_journal_xls_parser) parser=account_journal_xls_parser)

View File

@ -1,25 +1,6 @@
# -*- encoding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # Copyright 2009-2016 Noviat
# # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# OpenERP, Open Source Management Solution
#
# Copyright (c) 2014 Noviat nv/sa (www.noviat.com). All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import xlwt import xlwt
from datetime import datetime from datetime import datetime
from openerp.osv import orm from openerp.osv import orm
@ -368,6 +349,7 @@ class move_line_xls(report_xls):
row_pos = self.xls_write_row( row_pos = self.xls_write_row(
ws, row_pos, row_data, row_style=self.rt_cell_style_right) ws, row_pos, row_data, row_style=self.rt_cell_style_right)
move_line_xls('report.move.line.list.xls', move_line_xls('report.move.line.list.xls',
'account.move.line', 'account.move.line',
parser=move_line_xls_parser) parser=move_line_xls_parser)