odoo/odoo#193627

Created by fw-bot
Merged at 8397287faa8213ba2cb516026189a23632aa32b9

Statuses:

label
odoo-dev:saas-18.1-17.0-currency_access_child_comp-arsi-VJgY-fw
head
d224f0d6ecd53e4bbf15c9a3398fe0e71b269229
merged
9 months ago by Accounting, William André (wan)
odoo/odoo
17.0 #192632
saas-17.2 #192959
saas-17.4 #192970
18.0 #192982
saas-18.1 #193627
saas-18.2
saas-18.3
saas-18.4
19.0
master #193810

[FW][FIX] base: fix access error to currencies when in child company

Steps to reproduce (db with Accounting installed):
- create a child company
- give a user (e.g. Marc Demo) access to the child company, set
their "Accounting" rights to "Accountant" and "Administration" to None.
- log as this user and select only the child company in the company
selector.
- try to access "Accounting/Configuration/Accounting/Currencies"
-> Access Error

It is happening as in the res.currency model, several methods try to
access the root company, but there's only the child company in
allowed_company_ids from the context.

The fix here is to:
1) When accessing the root company in order the get its currency, just
access the currency of the child company, as it is the same.
2) Use sudo when accessing other fields from the root company.

opw-4352595

Forward-Port-Of: #192982
Forward-Port-Of: #192632