odoo/odoo#193810

Created by fw-bot
Merged at 278af47158d583b370ff7a118b79c5cf6b2ebccf

Statuses:

label
odoo-dev:master-17.0-currency_access_child_comp-arsi-uyol-fw
head
f4db5d0b6ddc4927392eb07b3d8f578e5e205c75
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: #193627
Forward-Port-Of: #192632