Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Redner Odoo Module
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XCG
Odoo modules
Redner Odoo Module
Commits
b3ce7077
Commit
b3ce7077
authored
4 months ago
by
oury.balde
Browse files
Options
Downloads
Patches
Plain Diff
Fix: ensure Redner instance reflects updated system parameters
parent
ac6896ba
No related branches found
No related tags found
1 merge request
!67
Implement caching and optimization for Redner template handling
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
NEWS.rst
+5
-0
5 additions, 0 deletions
NEWS.rst
__manifest__.py
+1
-1
1 addition, 1 deletion
__manifest__.py
models/redner_template.py
+23
-10
23 additions, 10 deletions
models/redner_template.py
with
29 additions
and
11 deletions
NEWS.rst
+
5
−
0
View file @
b3ce7077
...
...
@@ -2,6 +2,11 @@
Changelog
=========
18.0.1.0.2
----------
Fix: ensure Redner instance reflects updated system parameters.
18.0.1.0.1
----------
...
...
This diff is collapsed.
Click to expand it.
__manifest__.py
+
1
−
1
View file @
b3ce7077
...
...
@@ -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/
"
,
...
...
This diff is collapsed.
Click to expand it.
models/redner_template.py
+
23
−
10
View file @
b3ce7077
...
...
@@ -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
(
c
onfig_model
.
get_param
(
"
redner.
api_key
"
)
,
c
onfig_model
.
get_param
(
"
redner.
server_url
"
)
,
c
onfig_model
.
get_param
(
"
redner.
account
"
)
,
int
(
config_model
.
get_param
(
"
redner.timeout
"
,
default
=
"
20
"
))
,
c
urrent_params
[
"
api_key
"
]
,
c
urrent_params
[
"
server_url
"
]
,
c
urrent_params
[
"
account
"
]
,
current_params
[
"
timeout
"
]
,
)
...
...
@@ -287,4 +299,5 @@
)
_redner_params
=
current_params
# Update the stored parameters
return
_redner
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment