odoo/odoo#192632

Created by Accounting, Arnaud Sibille (arsi)
Merged at e46c77a004ef723090e1491dc28a41200a990500

Statuses:

label
odoo-dev:17.0-currency_access_child_comp-arsi
head
be1e5ed4703be888e31f4243eee5d735dcb0d698
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

[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