summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorNasreddin (bon) <bon@odoo.com>2021-04-12 18:53:58 +0000
committerNasreddin (bon) <bon@odoo.com>2021-04-14 15:26:06 +0000
commit9b45e7f5749dc86e9fa3c0b4ebc7de700774923a (patch)
tree0ed96811baa70956a8e378f575c060ea26edcb0d /addons
parentc8c68a07199124091e8d49946a63fb8c705c2417 (diff)
[FIX] portal: display discounts on quotation pdf for portal user
Issue - Install "Sale" app - Acivate "Discounts" feature in settings - Create a quotation to a portal user (ex: Joel Willis) - Add a product with a discount then send - Logout then login as 'Joel Willis' - Go to 'My account' then 'Quotations' - Select the quotation just created and print it Discount not display in pdf file. Cause The current env.user when rendering pdf is the portal user. To display discount, current env.user must have group 'product.group_discount_per_so_line' who is not the case even when using sudo() on report template. Solution Since Odoo 13.0, the sudo() function does not return the superuser by default but instead the current user with a bypass on access rights. Therefore, must add `.with_user(SUPERUSER_ID)` on report. opw-2501337 closes odoo/odoo#69265 X-original-commit: 5dde19c92ecee8ac0238bb5c8e71263840534c28 Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/portal/controllers/portal.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/portal/controllers/portal.py b/addons/portal/controllers/portal.py
index 548b72ef8e4..be3a6eabf34 100644
--- a/addons/portal/controllers/portal.py
+++ b/addons/portal/controllers/portal.py
@@ -405,7 +405,7 @@ class CustomerPortal(Controller):
if report_type not in ('html', 'pdf', 'text'):
raise UserError(_("Invalid report type: %s", report_type))
- report_sudo = request.env.ref(report_ref).sudo()
+ report_sudo = request.env.ref(report_ref).with_user(SUPERUSER_ID)
if not isinstance(report_sudo, type(request.env['ir.actions.report'])):
raise UserError(_("%s is not the reference of a report", report_ref))