Skip to content
Snippets Groups Projects
Commit 5efa30c3 authored by Nans Lefebvre's avatar Nans Lefebvre Committed by fw-bot
Browse files

[FIX] fields, test_access_rights: get currency field in sudo


This commits fixes user duplication.

Suppose there is a monetary field, with a currency_field that is a related.
When going through model's _create, we do:
`if field.type in ('one2many', 'many2many'):
    self.env.cache.set(record, field, ())`
knowing that thse values are false, with the intent to clean them later:
`for record, field in cachetoclear`
However, when setting the scalar values, we go through:
`accessing cache_value = field.convert_to_cache(value, record)`
In the case of the monetary field, this depends on another field value
(the currency_field). If it is a related, we can access its value.
However, at this point, if we check any access rights, we might use the value
of a relational in cache for which the value is incorrectly set to False.

In the case of the user, this is what happens: it inherits its currency_id
from partner, as well as its debit_limit which depends on it.
When the access if checked, company_ids is set to False in cache.
So when going through the rule 'user rule', which checks that the company_ids
intersects with the env.companies.ids, the result is always False.

In some way this is essentially hiding the problem, but the true fix is
probably not feasible in stable.

opw 2086661

closes odoo/odoo#39017

X-original-commit: aa05a935
Signed-off-by: default avatarNans Lefebvre (len) <len@odoo.com>
parent 2cab9a83
Branches
Tags
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment