-
-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[14.0][FIX] product_multi_company: recompute variant companies #590
[14.0][FIX] product_multi_company: recompute variant companies #590
Conversation
437b94b
to
7900459
Compare
7900459
to
aa7bd6e
Compare
This doesn't seem the correct approach, as it causes an overhead on all models. Why don't you redefine the field as computed in product variant, like other fields like |
Looks like it worked as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review, I think this is the correct solution for the problem, just a few minor.
comodel_name="res.company", | ||
relation="product_variant_companies_rel", | ||
compute="_compute_company_ids", | ||
store=True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: do you think a compute_sudo=True
is warranted here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it needs to be computed with current user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I understand of the base module, company_ids
contains all the companies (including the ones the current user cannot see) and it's company_id
that needs to be computed with the current user.
In general, if it needs to be computed with the current user it shouldn't be stored, and the other way around as well, if it's stored, the result shouldn't change depending on the user that last triggered the computation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Could this just be a related field? I don't know if it would work that way)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is related by default because of inheritance. Even if you make that relation explicit it doesnt work. As well as with store=False.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't depend on the current user for sure. The problem is that I'm giving you tips blindly, as I don't understand the reported issue and it doesn't seem related to this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there something I can improve in the issue itself to make it clearer? Is there anything in particular that you think is underexplained?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that I can't reproduce the issue in this runboat:
and the error message about company employee rule indicates an issue with other module, not this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, reproduced in base DB.
59e8596
to
bb4fcee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you avoid to store the field to see if the error persists?
comodel_name="res.company", | ||
relation="product_variant_companies_rel", | ||
compute="_compute_company_ids", | ||
store=True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, reproduced in base DB.
With store=False error is still there |
Uhm, that's very weird. This should be an ORM fault, as there's nothing in the business side leading to the problem. OK, restore it and clean commit history, and let me check once again. |
076599a
to
77d77d5
Compare
77d77d5
to
d248a27
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to work.
I think the inner problem is that in v13 it was falsely assumed that there's no need now to remove the auxiliary model:
https://github.com/OCA/multi-company/blob/12.0/base_multi_company/models/res_company_assignment.py
/ocabot merge minor |
This PR looks fantastic, let's merge it! |
Congratulations, your PR was merged at ec4609a. Thanks a lot for contributing to OCA. ❤️ |
FIX #585
Need to force recompute related product.product company_ids field. Otherwise it takes wrong values from the cache.