Skip to content
Snippets Groups Projects
Commit b3ce7077 authored by oury.balde's avatar oury.balde
Browse files

Fix: ensure Redner instance reflects updated system parameters

parent ac6896ba
No related branches found
No related tags found
1 merge request!67Implement caching and optimization for Redner template handling
......@@ -2,6 +2,11 @@
Changelog
=========
18.0.1.0.2
----------
Fix: ensure Redner instance reflects updated system parameters.
18.0.1.0.1
----------
......
......@@ -21,7 +21,7 @@
{
"name": "Redner",
"license": "AGPL-3",
"version": "18.0.1.0.1",
"version": "18.0.1.0.2",
"category": "Reporting",
"author": "XCG Consulting",
"website": "https://orbeet.io/",
......
......@@ -272,10 +272,10 @@
@property
def redner(self):
"""Try to avoid Redner instance to be over created"""
global _redner
if _redner is None:
# Bypass security rules when reading these configuration params. By
# default, only some administrators have access to that model.
config_model = self.env["ir.config_parameter"].sudo()
"""
Returns a Redner instance.
Recomputes the instance if any system parameter changes.
Uses a global variable to cache the instance across sessions.
"""
global _redner, _redner_params
......@@ -281,2 +281,14 @@
# Fetch current system parameters
config_model = self.env["ir.config_parameter"].sudo()
current_params = {
"api_key": config_model.get_param("redner.api_key"),
"server_url": config_model.get_param("redner.server_url"),
"account": config_model.get_param("redner.account"),
"timeout": int(config_model.get_param("redner.timeout", default="20")),
}
# Check if parameters have changed or if _redner is None
if _redner is None or _redner_params != current_params:
# Recompute the Redner instance
_redner = Redner(
......@@ -282,6 +294,6 @@
_redner = Redner(
config_model.get_param("redner.api_key"),
config_model.get_param("redner.server_url"),
config_model.get_param("redner.account"),
int(config_model.get_param("redner.timeout", default="20")),
current_params["api_key"],
current_params["server_url"],
current_params["account"],
current_params["timeout"],
)
......@@ -287,4 +299,5 @@
)
_redner_params = current_params # Update the stored parameters
return _redner
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment