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
closesodoo/odoo#69272
X-original-commit: 5dde19c92ecee8ac0238bb5c8e71263840534c28
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>