[MIG] report_context: Migration to 16.0
parent
9ad28eef82
commit
717f79a8c8
|
@ -5,7 +5,7 @@
|
|||
"name": "Report Context",
|
||||
"summary": """
|
||||
Adding context to reports""",
|
||||
"version": "14.0.1.0.2",
|
||||
"version": "16.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"author": "Creu Blanca,Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/reporting-engine",
|
||||
|
|
|
@ -4,7 +4,7 @@ import json
|
|||
|
||||
from odoo.http import request, route
|
||||
|
||||
from odoo.addons.web.controllers import main as report
|
||||
from odoo.addons.web.controllers import report as report
|
||||
|
||||
|
||||
class ReportController(report.ReportController):
|
||||
|
@ -13,7 +13,7 @@ class ReportController(report.ReportController):
|
|||
report = request.env["ir.actions.report"]._get_report_from_name(reportname)
|
||||
original_context = json.loads(data.get("context", "{}") or "{}")
|
||||
data["context"] = json.dumps(
|
||||
report.with_context(original_context)._get_context()
|
||||
report.with_context(**original_context)._get_context()
|
||||
)
|
||||
return super().report_routes(
|
||||
reportname, docids=docids, converter=converter, **data
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<odoo noupdate="1">
|
||||
<record
|
||||
id="report_default_context"
|
||||
model="ir.config_parameter"
|
||||
forcecreate="True"
|
||||
>
|
||||
id="report_default_context"
|
||||
model="ir.config_parameter"
|
||||
forcecreate="True"
|
||||
>
|
||||
<field name="key">report.default.context</field>
|
||||
<field name="value">{}</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
|
@ -16,7 +16,6 @@ class IrActionsReport(models.Model):
|
|||
)
|
||||
|
||||
def _get_context(self):
|
||||
self.ensure_one()
|
||||
context = (
|
||||
self.env["ir.config_parameter"]
|
||||
.sudo()
|
||||
|
@ -29,12 +28,12 @@ class IrActionsReport(models.Model):
|
|||
context.update(self.env.context)
|
||||
return context
|
||||
|
||||
def _render(self, res_ids, data=None):
|
||||
return super(IrActionsReport, self.with_context(self._get_context()))._render(
|
||||
res_ids, data=data
|
||||
def _render(self, report_ref, res_ids, data=None):
|
||||
return super(IrActionsReport, self.with_context(**self._get_context()))._render(
|
||||
report_ref, res_ids, data=data
|
||||
)
|
||||
|
||||
def report_action(self, docids, data=None, config=True):
|
||||
return super(
|
||||
IrActionsReport, self.with_context(self._get_context())
|
||||
IrActionsReport, self.with_context(**self._get_context())
|
||||
).report_action(docids, data=data, config=config)
|
||||
|
|
Loading…
Reference in New Issue