+
-
+
Periods:
- Start Period:
- End Period:
+ Start Period:
+ End Period:
diff --git a/addons/report/controllers/main.py b/addons/report/controllers/main.py
index c6bc13d38f8..01992d64c60 100644
--- a/addons/report/controllers/main.py
+++ b/addons/report/controllers/main.py
@@ -50,7 +50,12 @@ class ReportController(Controller):
if data.get('options'):
options_data = simplejson.loads(data['options'])
if data.get('context'):
- context.update(simplejson.loads(data['context']))
+ # Ignore 'lang' here, because the context in data is the one from the webclient *but* if
+ # the user explicitely wants to change the lang, this mechanism overwrites it.
+ data_context = simplejson.loads(data['context'])
+ if data_context.get('lang'):
+ del data_context['lang']
+ context.update(data_context)
if converter == 'html':
html = report_obj.get_html(cr, uid, docids, reportname, data=options_data, context=context)
diff --git a/addons/report/models/report.py b/addons/report/models/report.py
index 17635688063..099055c18dd 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
#--------------------------------------------------------------------------
@@ -133,7 +114,9 @@ class Report(osv.Model):
user = self.pool['res.users'].browse(cr, uid, uid)
website = None
if request and hasattr(request, 'website'):
- website = request.website
+ if request.website is not None:
+ website = request.website
+ context.update(translatable=context.get('lang') != request.website.default_lang_code)
values.update(
time=time,
translate_doc=translate_doc,
@@ -141,7 +124,7 @@ class Report(osv.Model):
user=user,
res_company=user.company_id,
website=website,
- editable_no_editor=True,
+ editable_no_editor=_("The preferred way to edit a report is to use the HTML Editor"),
)
return view_obj.render(cr, uid, template, values, context=context)
@@ -191,13 +174,16 @@ class Report(osv.Model):
paperformat = report.paperformat_id
# Preparing the minimal html pages
- subst = " "
css = '' # Will contain local css
headerhtml = []
contenthtml = []
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=True, 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=True, 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=False, 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
@@ -254,11 +240,10 @@ class Report(osv.Model):
specific_paperformat_args[attribute[0]] = attribute[1]
# Run wkhtmltopdf process
- pdf = self._generate_wkhtml_pdf(
+ return self._run_wkhtmltopdf(
cr, uid, headerhtml, footerhtml, contenthtml, context.get('landscape'),
paperformat, specific_paperformat_args, save_in_attachment
)
- return pdf
def get_action(self, cr, uid, ids, report_name, data=None, context=None):
"""Return an action of type ir.actions.report.xml.
@@ -329,7 +314,7 @@ class Report(osv.Model):
def _check_wkhtmltopdf(self):
return wkhtmltopdf_state
- def _generate_wkhtml_pdf(self, cr, uid, headers, footers, bodies, landscape, paperformat, spec_paperformat_args=None, save_in_attachment=None):
+ def _run_wkhtmltopdf(self, cr, uid, headers, footers, bodies, landscape, paperformat, spec_paperformat_args=None, save_in_attachment=None):
"""Execute wkhtmltopdf as a subprocess in order to convert html given in input into a pdf
document.
diff --git a/addons/report/views/layouts.xml b/addons/report/views/layouts.xml
index f9c0ea7ef73..a632dff661a 100644
--- a/addons/report/views/layouts.xml
+++ b/addons/report/views/layouts.xml
@@ -1,55 +1,31 @@
+
+
+
+ data_report_margin_top if data_report_margin_top else None
+ data_report_header_spacing if data_report_header_spacing else None
+ data_report_dpi if data_report_dpi else None
+
+
+
+
+
+
+
+
+
+
+
+
- <!DOCTYPE html>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
@@ -164,5 +140,25 @@
+
+
+ <!DOCTYPE html>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/sale/views/report_saleorder.xml b/addons/sale/views/report_saleorder.xml
index 5c198c635a3..a6771823f55 100644
--- a/addons/sale/views/report_saleorder.xml
+++ b/addons/sale/views/report_saleorder.xml
@@ -65,7 +65,7 @@
-
+
|
diff --git a/addons/website/models/website.py b/addons/website/models/website.py
index 5061b302fb7..51e31fe1c38 100644
--- a/addons/website/models/website.py
+++ b/addons/website/models/website.py
@@ -244,7 +244,7 @@ class website(osv.osv):
return is_website_publisher
def is_user(self, cr, uid, ids, context=None):
- return self.pool['res.users'].has_group(cr, request.uid, 'base.group_user')
+ return self.pool['res.users'].has_group(cr, uid, 'base.group_user')
def get_template(self, cr, uid, ids, template, context=None):
if isinstance(template, (int, long)):
diff --git a/addons/website/views/website_backend_navbar.xml b/addons/website/views/website_backend_navbar.xml
index 5b85180b5b8..d30e5415be1 100644
--- a/addons/website/views/website_backend_navbar.xml
+++ b/addons/website/views/website_backend_navbar.xml
@@ -4,6 +4,7 @@
+
-
-
-
-
-
+
+
+
+
|