+
diff --git a/addons/web_editor/models/ir_qweb.py b/addons/web_editor/models/ir_qweb.py
index 04b0253c3a2..f833607e205 100644
--- a/addons/web_editor/models/ir_qweb.py
+++ b/addons/web_editor/models/ir_qweb.py
@@ -146,10 +146,11 @@ class ManyToOne(models.AbstractModel):
@api.model
def attributes(self, record, field_name, options, values):
attrs = super(ManyToOne, self).attributes(record, field_name, options, values)
- many2one = getattr(record, field_name)
- if many2one:
- attrs['data-oe-many2one-id'] = many2one.id
- attrs['data-oe-many2one-model'] = many2one._name
+ if options.get('inherit_branding'):
+ many2one = getattr(record, field_name)
+ if many2one:
+ attrs['data-oe-many2one-id'] = many2one.id
+ attrs['data-oe-many2one-model'] = many2one._name
return attrs
@api.model
@@ -175,8 +176,9 @@ class Contact(models.AbstractModel):
@api.model
def attributes(self, record, field_name, options, values):
attrs = super(Contact, self).attributes(record, field_name, options, values)
- options.pop('template_options') # remove options not specific to this widget
- attrs['data-oe-contact-options'] = json.dumps(options)
+ if options.get('inherit_branding'):
+ options.pop('template_options') # remove options not specific to this widget
+ attrs['data-oe-contact-options'] = json.dumps(options)
return attrs
# helper to call the rendering of contact field
@@ -192,7 +194,8 @@ class Date(models.AbstractModel):
@api.model
def attributes(self, record, field_name, options, values):
attrs = super(Date, self).attributes(record, field_name, options, values)
- attrs['data-oe-original'] = record[field_name]
+ if options.get('inherit_branding'):
+ attrs['data-oe-original'] = record[field_name]
return attrs
@api.model
@@ -211,14 +214,15 @@ class DateTime(models.AbstractModel):
@api.model
def attributes(self, record, field_name, options, values):
attrs = super(DateTime, self).attributes(record, field_name, options, values)
- value = record[field_name]
- if isinstance(value, pycompat.string_types):
- value = fields.Datetime.from_string(value)
- if value:
- # convert from UTC (server timezone) to user timezone
- value = fields.Datetime.context_timestamp(self, timestamp=value)
- value = fields.Datetime.to_string(value)
- attrs['data-oe-original'] = value
+ if options.get('inherit_branding'):
+ value = record[field_name]
+ if isinstance(value, pycompat.string_types):
+ value = fields.Datetime.from_string(value)
+ if value:
+ # convert from UTC (server timezone) to user timezone
+ value = fields.Datetime.context_timestamp(self, timestamp=value)
+ value = fields.Datetime.to_string(value)
+ attrs['data-oe-original'] = value
return attrs
@api.model
@@ -398,7 +402,8 @@ class Duration(models.AbstractModel):
@api.model
def attributes(self, record, field_name, options, values):
attrs = super(Duration, self).attributes(record, field_name, options, values)
- attrs['data-oe-original'] = record[field_name]
+ if options.get('inherit_branding'):
+ attrs['data-oe-original'] = record[field_name]
return attrs
@api.model
diff --git a/odoo/addons/base/models/ir_actions_report.py b/odoo/addons/base/models/ir_actions_report.py
index a1761a6759b..44d25b3df01 100644
--- a/odoo/addons/base/models/ir_actions_report.py
+++ b/odoo/addons/base/models/ir_actions_report.py
@@ -311,16 +311,17 @@ class IrActionsReport(models.Model):
# Retrieve bodies
for node in root.xpath(match_klass.format('article')):
- body = layout.render(dict(subst=False, body=lxml.html.tostring(node), base_url=base_url))
- bodies.append(body)
- oemodelnode = node.find(".//*[@data-oe-model='%s']" % self.model)
- if oemodelnode is not None:
- res_id = oemodelnode.get('data-oe-id')
- if res_id:
- res_id = int(res_id)
+ if node.get('data-oe-model') == self.model:
+ body = layout.render(dict(subst=False, body=lxml.html.tostring(node), base_url=base_url))
+ bodies.append(body)
+ res_ids.append(int(node.get('data-oe-id', False)))
else:
- res_id = False
- res_ids.append(res_id)
+ _logger.warning("The report's template '%s' does not contains the attributes 'data-oe-model' and 'data-oe-id' on the container (with class 'article')", self.name)
+ raise UserError(_("The report's template is wrong, please contact your administrator"))
+
+ if not bodies:
+ _logger.warning("The report's template '%s' does not contains the container with the class 'article'", self.name)
+ raise UserError(_("The report's template is wrong, please contact your administrator"))
# Get paperformat arguments set in the root html tag. They are prioritized over
# paperformat-record arguments.
@@ -454,7 +455,7 @@ class IrActionsReport(models.Model):
if values is None:
values = {}
- context = dict(self.env.context, inherit_branding=True) # Tell QWeb to brand the generated html
+ context = dict(self.env.context, inherit_branding=values.get('enable_editor'))
# Browse the user instead of using the sudo self.env.user
user = self.env['res.users'].browse(self.env.uid)
@@ -468,7 +469,7 @@ class IrActionsReport(models.Model):
values.update(
time=time,
context_timestamp=lambda t: fields.Datetime.context_timestamp(self.with_context(tz=user.tz), t),
- editable=True,
+ editable=values.get('enable_editor'),
user=user,
res_company=user.company_id,
website=website,
@@ -568,6 +569,12 @@ class IrActionsReport(models.Model):
@api.multi
def render_qweb_pdf(self, res_ids=None, data=None):
+ if not data:
+ data = {}
+
+ # remove editor feature in pdf generation
+ data.update(enable_editor=False)
+
# In case of test environment without enough workers to perform calls to wkhtmltopdf,
# fallback to render_html.
if tools.config['test_enable']:
@@ -675,11 +682,13 @@ class IrActionsReport(models.Model):
data = report_model._get_report_values(docids, data=data)
else:
docs = self.env[self.model].browse(docids)
- data = {
+ if not data:
+ data = {}
+ data.update({
'doc_ids': docids,
'doc_model': self.model,
'docs': docs,
- }
+ })
return data
@api.multi
diff --git a/odoo/addons/base/report/ir_model_templates.xml b/odoo/addons/base/report/ir_model_templates.xml
index 1d64d246520..0ca63091dcb 100644
--- a/odoo/addons/base/report/ir_model_templates.xml
+++ b/odoo/addons/base/report/ir_model_templates.xml
@@ -3,7 +3,7 @@
-