[18.0][FIX] base_multi_company: 'company_id' use all common companies #910
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this commit, we could have wrong access errors on records. As an example, if we had a user with enabled companies A and C (being A the main company) and a record with enabled companies B and C, we would get and access error.
That's because the
company_idfor the record was set to B (since it did not match with the user's main company, A, it took the first of the enabled companies for the record). But it should be set to C, because it's the first common company between the user and the record, and that would allow us to access the record without any error. Also added new use cases in the testing to check this behavior. Without the code changes in the commit, the test fails.