[IMP] report_context: black, isort, prettier

This commit is contained in:
Jaime Arroyo
2020-09-30 12:06:33 +02:00
committed by Pierrick Brun
parent 5a12000272
commit 4d8f393d1e
7 changed files with 77 additions and 72 deletions

View File

@@ -1,36 +1,42 @@
# Copyright 2019 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tools.safe_eval import safe_eval
from odoo import api, fields, models
from odoo.tools.safe_eval import safe_eval
class IrActionsReport(models.Model):
_inherit = 'ir.actions.report'
_inherit = "ir.actions.report"
context = fields.Char(
string='Context Value', default={},
string="Context Value",
default={},
required=True,
help="Context dictionary as Python expression, empty by default "
"(Default: {})")
"(Default: {})",
)
def _get_context(self):
self.ensure_one()
context = self.env['ir.config_parameter'].sudo().get_param(
'report.default.context', '{}')
context = (
self.env["ir.config_parameter"]
.sudo()
.get_param("report.default.context", "{}")
)
# We must transform it to a dictionary
context = safe_eval(context or '{}')
report_context = safe_eval(self.context or '{}')
context = safe_eval(context or "{}")
report_context = safe_eval(self.context or "{}")
context.update(report_context)
context.update(self.env.context)
return context
@api.multi
def render(self, res_ids, data=None):
return super(IrActionsReport, self.with_context(
self._get_context())).render(res_ids, data=data)
return super(IrActionsReport, self.with_context(self._get_context())).render(
res_ids, data=data
)
@api.noguess
def report_action(self, docids, data=None, config=True):
return super(IrActionsReport, self.with_context(
self._get_context()
)).report_action(docids, data=data, config=config)
return super(
IrActionsReport, self.with_context(self._get_context())
).report_action(docids, data=data, config=config)