Daily updates from Odoo
Wednesday, August 10, 2016
1 change · master
Resolved issues and error corrections
This fix ensures reports receive the correct selected records when generating HTML output, preventing reports from using the wrong document IDs. It improves reliability for several accounting, payroll, manufacturing, point of sale, product, and HR reports, especially when users print reports from standard actions or wizards.
Original PR description
Description of the issue/feature this PR addresses: Current behavior before PR: Desired behavior after PR is merged: ## I confirm I have signed the CLA and read the PR guidelines at…
Description of the issue/feature this PR addresses:
Current behavior before PR:
Desired behavior after PR is merged:
##
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
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)'
As get_html has become an api.model method, the docids are not passed anymore, and
the call to render_html should be replaced by
```
if report_model is not None:
return report_model.render_html(docids, 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):
```
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.