summaryrefslogtreecommitdiff
path: root/doc/reference
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2016-08-09 17:06:28 +0200
committerYannick Tivisse <yti@odoo.com>2016-08-10 11:13:33 +0200
commita3f83916d0c9152c9d5076782ee41f1adb06d679 (patch)
treeac3064b62160c5e2211665fca264c2169e945d3e /doc/reference
parent2fcbf1258deb19af611d69c15ff9870835f9f153 (diff)
[FIX] report: Pass correctly the docids to render_html method
In the 'get_html' method, the report is using a custom model to render its html, we should use its own 'render_html' method to generate the report. During the module migration, we replaced 'report_model.render_html(cr, uid, ids, data=data, context=context)' by 'report_model.render_html(data=data)' The new API signature of 'get_html' is @api.model def get_html(self, docids, report_name, data=None): That way, 'render_html' doesn't receive docids anymore when called. We should do instead if report_model is not None: return report_model.browse(docids).render_html(data=data) As render_html is an api.multi method, this is all wrong too, because we'll send a browse record with the custom report model to the render_html method, to use the ids with 'self.ids' that are absolutely not corresponding to the report model but to to the record model we want to print (an invoice for example). In old API style we were sending a list of ids, but it's not correct to keep the same behavior by sending a browse record with only the ids relevant. We have also to change render_html method decorator to @api.model with a new signature @api.model def render_html(self, docids, data=None): And replace the call to render_html by if report_model is not None: return report_model.render_html(docids, data=data) In the case the report is printed from a wizard, this is sufficient because the ids are taken from the active_ids in context, or in data. In the case the report is printed from a simple action, we should replace the occurence of 'self.ids' (which doesn't mean anything) to 'docids' This fix doesn't solve the printing issues for the custom accounting reports, because the method get_pdf has been reimplemented in the module account_reports.
Diffstat (limited to 'doc/reference')
-rw-r--r--doc/reference/reports.rst6
1 files changed, 3 insertions, 3 deletions
diff --git a/doc/reference/reports.rst b/doc/reference/reports.rst
index 854ee58677b..830bc3460fc 100644
--- a/doc/reference/reports.rst
+++ b/doc/reference/reports.rst
@@ -290,12 +290,12 @@ the function ``render_html`` and pass objects in the ``docargs`` dictionary:
class ParticularReport(models.AbstractModel):
_name = 'report.module.report_name'
- @api.multi
- def render_html(self, data=None):
+ @api.model
+ def render_html(self, docids, data=None):
report_obj = self.env['report']
report = report_obj._get_report_from_name('module.report_name')
docargs = {
- 'doc_ids': self._ids,
+ 'doc_ids': docids,
'doc_model': report.model,
'docs': self,
}