I'd really like to understand Odoo access rights and rules, everything seems beautiful and perfect but the actual fact is that it's almost impossible to make them work OK.
An example of what I'm refering to is this kind of situations (I had this one time ago and I had to avoid using rules to solve it): Are Odoo rules working OK actually?
Now I'm facing another problem: I'm using multicompany, and there are some users whose behaviour affects the rest. For example, I have this company tree:
Main Company
|_ Company A
|_ Company B
The user Administrator belongs to Main Company. Then I have an user named Forvas who belongs to Company B and only can work with customers /suppliers of that company. Now, I'm moving the Administrator from Main Company, to work with Company A. From that moment on, the user Forvas can't see customers or suppliers of Company B (something that he was able to do earlier), and he just gets the Access Rights error: res.users - Operation: read each time he tries to open any customer or supplier he's expected to see. You can just tell me that the user Administrator must be always in the Main Company and never move himself to work with other one, so I'll respect that, but the problem is that other users who can work with Main Company also spark the same error when they start working with other company (like Company A). For example, an user named The Chief can work with all companies, but he decides to work with Company A. Well, user Forvas stops seeing customers/suppliers of Company B, he gets the Access Rights error when he tries to open anyone...
Then I added some log lines to fields.py
file, to try to find the problem. Then I realized that there's a field made by myself which is giving the problem, but the field isn't such an uncommon one. It's a Float
which is computed, declared in res.partner
model. I've modified the field to simplify it (although the code now is a nosense since the field always values 0.0).
@api.multi
@api.depends('whatever')
def _compute_available_credit(self):
for partner in self:
partner.available_credit = 0.0
available_credit = fields.Float(
compute='_compute_available_credit',
string='Available credit',
)
I wrote whatever
inside the @api.depends
, it's not a field, but it doesn't matter which field I write there, the compute method always sparks the error.
However, if I comment the compute
parameter in the field declaration, the problem disappears...
So, can anyone explain me why? I'm fed up with dealing with Odoo security problems, I'm pretty sure that everyone must have these unexpected behaviours too because they happen to me every now and again.