mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
Style cleanup
This commit is contained in:
@@ -21,4 +21,3 @@
|
||||
from . import report_assembler
|
||||
from . import assembled_report
|
||||
from . import ir_report
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
##############################################################################
|
||||
from openerp.osv import orm, fields
|
||||
|
||||
|
||||
class AssembledReport(orm.Model):
|
||||
_name = 'assembled.report'
|
||||
|
||||
@@ -37,6 +38,7 @@ class AssembledReport(orm.Model):
|
||||
|
||||
_defaults = {
|
||||
'sequence': 1,
|
||||
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(
|
||||
'company_id': lambda s, cr, uid, c: s.pool.get(
|
||||
'res.company')._company_default_get(
|
||||
cr, uid, 'assembled.report', context=c)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
from openerp.osv import orm
|
||||
from openerp import netsvc
|
||||
from openerp.report.report_sxw import rml_parse
|
||||
from report_assembler import PDFReportAssembler
|
||||
from .report_assembler import PDFReportAssembler
|
||||
|
||||
|
||||
def register_report(name, model, parser=rml_parse):
|
||||
@@ -30,7 +30,7 @@ def register_report(name, model, parser=rml_parse):
|
||||
if netsvc.Service._services.get(name, False):
|
||||
service = netsvc.Service._services[name]
|
||||
if isinstance(service, PDFReportAssembler):
|
||||
#already instantiated properly, skip it
|
||||
# already instantiated properly, skip it
|
||||
return
|
||||
if hasattr(service, 'parser'):
|
||||
parser = service.parser
|
||||
@@ -48,7 +48,8 @@ class ReportAssembleXML(orm.Model):
|
||||
|
||||
def register_all(self, cursor):
|
||||
value = super(ReportAssembleXML, self).register_all(cursor)
|
||||
cursor.execute("SELECT * FROM ir_act_report_xml WHERE report_type = 'assemblage'")
|
||||
cursor.execute(
|
||||
"SELECT * FROM ir_act_report_xml WHERE report_type = 'assemblage'")
|
||||
records = cursor.dictfetchall()
|
||||
for record in records:
|
||||
register_report(record['report_name'], record['model'])
|
||||
@@ -77,7 +78,8 @@ class ReportAssembleXML(orm.Model):
|
||||
|
||||
def create(self, cursor, user, vals, context=None):
|
||||
""" Create report and register it """
|
||||
res = super(ReportAssembleXML, self).create(cursor, user, vals, context)
|
||||
res = super(ReportAssembleXML, self).create(
|
||||
cursor, user, vals, context)
|
||||
if vals.get('report_type', '') == 'assemblage':
|
||||
# I really look forward to virtual functions :S
|
||||
register_report(
|
||||
@@ -105,6 +107,3 @@ class ReportAssembleXML(orm.Model):
|
||||
)
|
||||
res = super(ReportAssembleXML, self).write(cr, uid, ids, vals, context)
|
||||
return res
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -37,13 +37,13 @@ def assemble_pdf(pdf_list):
|
||||
# Even though we are using PyPDF2 we can't use PdfFileMerger
|
||||
# as this issue still exists in mostly used wktohtml reports version
|
||||
# http://code.google.com/p/wkhtmltopdf/issues/detail?id=635
|
||||
#merger = PdfFileMerger()
|
||||
#merger.append(fileobj=StringIO(invoice_pdf))
|
||||
#merger.append(fileobj=StringIO(bvr_pdf))
|
||||
# merger = PdfFileMerger()
|
||||
# merger.append(fileobj=StringIO(invoice_pdf))
|
||||
# merger.append(fileobj=StringIO(bvr_pdf))
|
||||
|
||||
#with tempfile.TemporaryFile() as merged_pdf:
|
||||
#merger.write(merged_pdf)
|
||||
#return merged_pdf.read(), 'pdf'
|
||||
# with tempfile.TemporaryFile() as merged_pdf:
|
||||
# merger.write(merged_pdf)
|
||||
# return merged_pdf.read(), 'pdf'
|
||||
|
||||
output = PdfFileWriter()
|
||||
for pdf in pdf_list:
|
||||
@@ -93,7 +93,8 @@ class PDFReportAssembler(report_sxw.report_sxw):
|
||||
|
||||
report_ids = self._get_report_ids(cr, uid, ids, context=context)
|
||||
|
||||
pdf_reports = self._generate_all_pdf(cr, uid, ids, data, report_ids, context=context)
|
||||
pdf_reports = self._generate_all_pdf(
|
||||
cr, uid, ids, data, report_ids, context=context)
|
||||
|
||||
pdf_assemblage = assemble_pdf(pdf_reports)
|
||||
return pdf_assemblage, 'pdf'
|
||||
@@ -103,8 +104,10 @@ class PDFReportAssembler(report_sxw.report_sxw):
|
||||
Code taken from report openoffice. Thanks guys :) """
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
ir_obj = pool.get('ir.actions.report.xml')
|
||||
report_xml_ids = ir_obj.search(cr, uid,
|
||||
[('report_name', '=', self.name[7:])], context=context)
|
||||
report_xml_ids = ir_obj.search(
|
||||
cr, uid,
|
||||
[('report_name', '=', self.name[7:])],
|
||||
context=context)
|
||||
if report_xml_ids:
|
||||
|
||||
report_xml = ir_obj.browse(cr,
|
||||
@@ -117,10 +120,13 @@ class PDFReportAssembler(report_sxw.report_sxw):
|
||||
report_xml.report_sxw_content = None
|
||||
report_xml.report_sxw = None
|
||||
else:
|
||||
return super(PDFReportAssembler, self).create(cr, uid, ids, data, context)
|
||||
return super(PDFReportAssembler, self).create(
|
||||
cr, uid, ids, data, context)
|
||||
if report_xml.report_type != 'assemblage':
|
||||
return super(PDFReportAssembler, self).create(cr, uid, ids, data, context)
|
||||
result = self.create_source_pdf(cr, uid, ids, data, report_xml, context)
|
||||
return super(PDFReportAssembler, self).create(
|
||||
cr, uid, ids, data, context)
|
||||
result = self.create_source_pdf(
|
||||
cr, uid, ids, data, report_xml, context)
|
||||
if not result:
|
||||
return (False, False)
|
||||
return result
|
||||
|
||||
@@ -35,12 +35,16 @@ This addon allows for custom filenames for reports.
|
||||
Configuration
|
||||
=============
|
||||
|
||||
To configure this module, open the report whose filename you want to change and fill in the `Download filename` field. This field is evaluated as jinja2 template with `objects` being a list of browse records of the records to print, and `o` the first record.
|
||||
To configure this module, open the report whose filename you want to change
|
||||
and fill in the `Download filename` field. This field is evaluated as jinja2
|
||||
template with `objects` being a list of browse records of the records to
|
||||
print, and `o` the first record.
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
* Currently, only old-style reports (ir.actions.report.xml) are supported, it should be simple to add support for qweb reports.
|
||||
* Currently, only old-style reports (ir.actions.report.xml) are supported,
|
||||
it should be simple to add support for qweb reports.
|
||||
|
||||
Credits
|
||||
=======
|
||||
@@ -65,7 +69,9 @@ Maintainer
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
To contribute to this module, please visit http://odoo-community.org.
|
||||
""",
|
||||
|
||||
@@ -36,7 +36,8 @@ class Reports(main.Reports):
|
||||
report_ids = report_xml.search(
|
||||
[('report_name', '=', action['report_name'])],
|
||||
0, False, False, context)
|
||||
for report in report_xml.read(report_ids, fields=['download_filename']):
|
||||
for report in report_xml.read(report_ids,
|
||||
fields=['download_filename']):
|
||||
if not report.get('download_filename'):
|
||||
continue
|
||||
objects = req.session.model(context['active_model'])\
|
||||
|
||||
@@ -30,7 +30,6 @@ import inspect
|
||||
from types import CodeType
|
||||
from openerp.report.report_sxw import report_sxw
|
||||
from openerp import pooler
|
||||
from openerp.tools.translate import translate, _
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -77,12 +76,11 @@ class report_xls(report_sxw):
|
||||
'fill': 'pattern: pattern solid, fore_color %s;' % _pfc,
|
||||
'fill_blue': 'pattern: pattern solid, fore_color 27;',
|
||||
'fill_grey': 'pattern: pattern solid, fore_color 22;',
|
||||
'borders_all':
|
||||
'borders: '
|
||||
'left thin, right thin, top thin, bottom thin, '
|
||||
'left_colour %s, right_colour %s, '
|
||||
'top_colour %s, bottom_colour %s;'
|
||||
% (_bc, _bc, _bc, _bc),
|
||||
'borders_all': 'borders: '
|
||||
'left thin, right thin, top thin, bottom thin, '
|
||||
'left_colour %s, right_colour %s, '
|
||||
'top_colour %s, bottom_colour %s;'
|
||||
% (_bc, _bc, _bc, _bc),
|
||||
'left': 'align: horz left;',
|
||||
'center': 'align: horz center;',
|
||||
'right': 'align: horz right;',
|
||||
|
||||
Reference in New Issue
Block a user