OCA / multi-company

GNU Affero General Public License v3.0
100 stars 281 forks source link

[15.0][FIX] base_multi_company: Proper _check_company when multiple companies selected #536

Closed pedrobaeza closed 9 months ago

pedrobaeza commented 9 months ago

Forward-port of #535

Steps to reproduce:

Result:

'Stock>Inventory adjustment' belongs to company 'C2' and 'Product' (product_id: 'Product 1') belongs to another company.

Explanation:

This is because the computed field company_id that is used for checking the product company vs the stock.move company (the error is not accurate, as it says the location, but it's the move), is returning the main company where the user is.

Solution:

Inject a context whenever we run _check_company for having available the company involved, and use that company as value for the record being checked if included in the allowed companies.

@Tecnativa

pedrobaeza commented 9 months ago

/ocabot merge patch

OCA-git-bot commented 9 months ago

What a great day to merge this nice PR. Let's do it! Prepared branch 15.0-ocabot-merge-pr-536-by-pedrobaeza-bump-patch, awaiting test results.

OCA-git-bot commented 9 months ago

Congratulations, your PR was merged at f4876155cecd9863501b9ca74c9c39ec9942f288. Thanks a lot for contributing to OCA. ❤️