From b02cc1ce72e40b49d9da0a391f62473f7b1d3567 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Mon, 25 Jul 2016 14:38:39 +0200 Subject: [PATCH] Fix linter warnings. --- report_xls/__init__.py | 3 +-- report_xls/__openerp__.py | 52 +-------------------------------------- report_xls/ir_report.py | 10 +++----- report_xls/report_xls.py | 17 ++++++------- report_xls/utils.py | 4 +-- 5 files changed, 15 insertions(+), 71 deletions(-) diff --git a/report_xls/__init__.py b/report_xls/__init__.py index e100e786..6325918e 100644 --- a/report_xls/__init__.py +++ b/report_xls/__init__.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution @@ -22,4 +22,3 @@ from . import ir_report from . import report_xls -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/report_xls/__openerp__.py b/report_xls/__openerp__.py index 31edb10b..65769da5 100644 --- a/report_xls/__openerp__.py +++ b/report_xls/__openerp__.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution @@ -26,57 +26,7 @@ 'author': "Noviat,Odoo Community Association (OCA)", 'website': 'http://www.noviat.com', 'category': 'Reporting', - 'description': """ -Excel report engine -=================== - -This module adds Excel export capabilities to the standard odoo reporting -engine. - -Report development -'''''''''''''''''' -In order to create an Excel report you can\n -- define a report of type 'xls' -- pass ``{'xls_export': 1}`` via the context to the report create method - -The ``report_xls`` class contains a number of attributes and methods to -facilitate the creation XLS reports in OpenERP. - -* cell types - - Supported cell types : text, number, boolean, date. - -* cell styles - - The predefined cell style definitions result in a consistent - look and feel of the OpenERP Excel reports. - -* cell formulas - - Cell formulas can be easily added with the help of the ``rowcol_to_cell()`` - function which you can import from the ``utils.py`` module. - -* Excel templates - - It is possible to define Excel templates which can be adapted - by 'inherited' modules. - Download the ``account_move_line_report_xls`` module - from http://apps.odoo.com as example. - -* XLS with multiple sheets - - Download the ``account_journal_report_xls`` module - from http://apps.odoo.com as example. - -Development assistance -'''''''''''''''''''''' -Contact info@noviat.com for help with the development of -Excel reports in odoo. - - """, 'depends': ['base'], 'external_dependencies': {'python': ['xlwt']}, - 'active': False, 'installable': True, } -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/report_xls/ir_report.py b/report_xls/ir_report.py index 332f32f0..ba6fb12e 100644 --- a/report_xls/ir_report.py +++ b/report_xls/ir_report.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution @@ -20,17 +20,15 @@ # ############################################################################## -from openerp.osv import orm +from openerp import models -class ir_actions_report_xml(orm.Model): +class IrActionsReportXml(models.Model): _inherit = 'ir.actions.report.xml' def _check_selection_field_value(self, cr, uid, field, value, context=None): if field == 'report_type' and value == 'xls': return - return super(ir_actions_report_xml, self)._check_selection_field_value( + return super(IrActionsReportXml, self)._check_selection_field_value( cr, uid, field, value, context=context) - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/report_xls/report_xls.py b/report_xls/report_xls.py index 347cb5e9..92a0940b 100644 --- a/report_xls/report_xls.py +++ b/report_xls/report_xls.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution @@ -44,7 +44,7 @@ class AttrDict(dict): self.__dict__ = self -class report_xls(report_sxw): +class ReportXls(report_sxw): xls_types = { 'bool': xlwt.Row.set_cell_boolean, @@ -112,7 +112,7 @@ class report_xls(report_sxw): # use model from 'data' when no ir.actions.report.xml entry self.table = data.get('model') or self.table return self.create_source_xls(cr, uid, ids, data, context) - return super(report_xls, self).create(cr, uid, ids, data, context) + return super(ReportXls, self).create(cr, uid, ids, data, context) def create_source_xls(self, cr, uid, ids, data, context=None): if not context: @@ -166,7 +166,8 @@ class report_xls(report_sxw): row = col_specs[wanted][rowtype][:] for i in range(len(row)): if isinstance(row[i], CodeType): - row[i] = eval(row[i], render_space) + # TODO Use safe_eval or document why not and remove pylint hack + row[i] = eval(row[i], render_space) # pylint: disable=W0123 row.insert(0, wanted) return row @@ -205,7 +206,7 @@ class report_xls(report_sxw): c.append({'formula': s[5]}) else: c.append({ - 'write_cell_func': report_xls.xls_types[c[3]]}) + 'write_cell_func': ReportXls.xls_types[c[3]]}) # Set custom cell style if s_len > 6 and s[6] is not None: c.append(s[6]) @@ -220,7 +221,7 @@ class report_xls(report_sxw): col += c[1] break if not found: - _logger.warn("report_xls.xls_row_template, " + _logger.warn("ReportXls.xls_row_template, " "column '%s' not found in specs", w) return r @@ -234,7 +235,7 @@ class report_xls(report_sxw): style = spec[6] and spec[6] or row_style if not data: # if no data, use default values - data = report_xls.xls_types_default[spec[3]] + data = ReportXls.xls_types_default[spec[3]] if size != 1: if formula: ws.write_merge( @@ -250,5 +251,3 @@ class report_xls(report_sxw): if set_column_size: ws.col(col).width = spec[2] * 256 return row_pos + 1 - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/report_xls/utils.py b/report_xls/utils.py index 943daae7..bb571846 100644 --- a/report_xls/utils.py +++ b/report_xls/utils.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution @@ -47,5 +47,3 @@ def rowcol_to_cell(row, col, row_abs=False, col_abs=False): chr2 = chr(ord('A') + m) # Zero index to 1-index return col_abs + chr1 + chr2 + row_abs + str(row + 1) - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: