Files
odoo_source/addons/analytic/models
Xavier Bol (xbo) f5d6a2db3b [FIX] analytic,sale: confirm SO with "expense" product
Before this commit, when a salesman user without any access in other
apps (just has the `sales_team.group_sale_salesman` group) creates
an SO and adds a SOL for a product with `expense_policy='sales_price'`
and then confirm the SO, he will got a traceback because he does not
have access to `analytic.account.line` model. The reason is because
an analytic account has to be generated for the SO since there is an
expense product in its SOLs and so during the generated of analytic
account a check is triggered to be sure the company set on that
analytic account is correct.

This commit adds a sudo before calling the search method in
`analytic.account.line` model to do the check without checking
the access right since the user does not really want to read the
analytic account line.

Steps to reproduce
==================
1. Log in as Salesman user (without other access)
2. Create a product and the expense policy to Sales price.
3. Create a SO and add a SOL with that product
4. Confirm the SO

Expected Behavior
=================
The SO should be confirmed without any issue (and an analytic account
should set on that SO)

Actual Behavior
===============
Traceback is occured because the user cannot access to
`analytic.account.line` model.

Follow-up task-3256865

closes odoo/odoo#155238

Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
2024-02-27 08:07:48 +00:00
..