Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
f2c1ee5a
Commit
f2c1ee5a
authored
4 years ago
by
Martin Trigaux
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] base: correct evaluation context for report rendering
Fix of
57665a02
which was problematic in point_of_sale
parent
ff1db4a6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
odoo/addons/base/models/ir_actions_report.py
+10
-10
10 additions, 10 deletions
odoo/addons/base/models/ir_actions_report.py
with
10 additions
and
10 deletions
odoo/addons/base/models/ir_actions_report.py
+
10
−
10
View file @
f2c1ee5a
...
...
@@ -730,13 +730,13 @@ class IrActionsReport(models.Model):
data
=
{}
data
.
setdefault
(
'
report_type
'
,
'
pdf
'
)
# access the report details with sudo() but evaluation context as
current u
se
r
# access the report details with sudo() but evaluation context as
sudo(Fal
se
)
self_sudo
=
self
.
sudo
()
# In case of test environment without enough workers to perform calls to wkhtmltopdf,
# fallback to render_html.
if
(
tools
.
config
[
'
test_enable
'
]
or
tools
.
config
[
'
test_file
'
])
and
not
self
.
env
.
context
.
get
(
'
force_report_rendering
'
):
return
self
.
_render_qweb_html
(
res_ids
,
data
=
data
)
return
self
_sudo
.
_render_qweb_html
(
res_ids
,
data
=
data
)
# As the assets are generated during the same transaction as the rendering of the
# templates calling them, there is a scenario where the assets are unreachable: when
...
...
@@ -833,7 +833,7 @@ class IrActionsReport(models.Model):
data
=
{}
data
.
setdefault
(
'
report_type
'
,
'
text
'
)
data
=
self
.
_get_rendering_context
(
docids
,
data
)
return
self
.
_render_template
(
self
.
sudo
().
report_name
,
data
),
'
text
'
return
self
.
_render_template
(
self
.
report_name
,
data
),
'
text
'
@api.model
def
_render_qweb_html
(
self
,
docids
,
data
=
None
):
...
...
@@ -843,29 +843,29 @@ class IrActionsReport(models.Model):
data
=
{}
data
.
setdefault
(
'
report_type
'
,
'
html
'
)
data
=
self
.
_get_rendering_context
(
docids
,
data
)
return
self
.
_render_template
(
self
.
sudo
().
report_name
,
data
),
'
html
'
return
self
.
_render_template
(
self
.
report_name
,
data
),
'
html
'
def
_get_rendering_context_model
(
self
):
report_model_name
=
'
report.%s
'
%
self
.
report_name
return
self
.
env
.
get
(
report_model_name
)
def
_get_rendering_context
(
self
,
docids
,
data
):
# access the report details with sudo() but evaluation context as current user
self_sudo
=
self
.
sudo
()
# If the report is using a custom model to render its html, we must use it.
# Otherwise, fallback on the generic html rendering.
report_model
=
self
_sudo
.
_get_rendering_context_model
()
report_model
=
self
.
_get_rendering_context_model
()
data
=
data
and
dict
(
data
)
or
{}
if
report_model
is
not
None
:
# _render_ may be executed in sudo but evaluation context as real user
report_model
=
report_model
.
sudo
(
False
)
data
.
update
(
report_model
.
_get_report_values
(
docids
,
data
=
data
))
else
:
docs
=
self
.
env
[
self_sudo
.
model
].
browse
(
docids
)
# _render_ may be executed in sudo but evaluation context as real user
docs
=
self
.
env
[
self
.
model
].
sudo
(
False
).
browse
(
docids
)
data
.
update
({
'
doc_ids
'
:
docids
,
'
doc_model
'
:
self
_sudo
.
model
,
'
doc_model
'
:
self
.
model
,
'
docs
'
:
docs
,
})
return
data
...
...
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