From: Simon Lejeune Date: Thu, 26 Jun 2014 14:34:31 +0000 (+0200) Subject: [IMP] report; minimal layout is now a qweb template, allowing users to customize... X-Git-Tag: InsPy_8.0_01~90^2~12^2~2 X-Git-Url: http://git.inspyration.org/?a=commitdiff_plain;h=03aaf7af1e2eba50a49a46698b0f1804747da5e7;p=odoo%2Fodoo.git [IMP] report; minimal layout is now a qweb template, allowing users to customize it. also make pypdf mandatory to start Odoo --- diff --git a/addons/report/models/report.py b/addons/report/models/report.py index 08cfec4..5bfc797 100644 --- a/addons/report/models/report.py +++ b/addons/report/models/report.py @@ -34,10 +34,8 @@ import lxml.html import cStringIO import subprocess from distutils.version import LooseVersion -try: - from pyPdf import PdfFileWriter, PdfFileReader -except ImportError: - PdfFileWriter = PdfFileReader = None +from functools import partial +from pyPdf import PdfFileWriter, PdfFileReader _logger = logging.getLogger(__name__) @@ -71,23 +69,6 @@ class Report(osv.Model): public_user = None - MINIMAL_HTML_PAGE = """ - - - - - - - - - - {subst} - - - {body} - -""" - #-------------------------------------------------------------------------- # Extension of ir_ui_view.render with arguments frequently used in reports #-------------------------------------------------------------------------- @@ -198,6 +179,11 @@ class Report(osv.Model): footerhtml = [] base_url = self.pool['ir.config_parameter'].get_param(cr, uid, 'web.base.url') + # Minimal page renderer + view_obj = self.pool['ir.ui.view'] + render_minimal = partial(view_obj.render, cr, uid, 'report.minimal_layout', context=context) + + # The received html report must be simplified. We convert it in a xml tree # in order to extract headers, bodies and footers. try: @@ -208,12 +194,12 @@ class Report(osv.Model): for node in root.xpath("//div[@class='header']"): body = lxml.html.tostring(node) - header = self.MINIMAL_HTML_PAGE.format(css=css, subst=subst, body=body, base_url=base_url) + header = render_minimal(dict(css=css, subst=subst, body=body, base_url=base_url)) headerhtml.append(header) for node in root.xpath("//div[@class='footer']"): body = lxml.html.tostring(node) - footer = self.MINIMAL_HTML_PAGE.format(css=css, subst=subst, body=body, base_url=base_url) + footer = render_minimal(dict(css=css, subst=subst, body=body, base_url=base_url)) footerhtml.append(footer) for node in root.xpath("//div[@class='page']"): @@ -230,7 +216,7 @@ class Report(osv.Model): reportid = False body = lxml.html.tostring(node) - reportcontent = self.MINIMAL_HTML_PAGE.format(css=css, subst='', body=body, base_url=base_url) + reportcontent = render_minimal(dict(css=css, subst='', body=body, base_url=base_url)) # FIXME: imo the best way to extract record id from html reports is by using the # qweb branding. As website editor is not yet splitted in a module independant from diff --git a/addons/report/views/layouts.xml b/addons/report/views/layouts.xml index 4de6717..e5ce9a8 100644 --- a/addons/report/views/layouts.xml +++ b/addons/report/views/layouts.xml @@ -150,5 +150,23 @@ + +