Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
5 Ответы
5363 Представления

I want to configure user to be able to create and edit users but only with his own allowed companies.
If I give him:
Administration - Access Rights
he is then able to create new users, but he can also give access to companies that he himself don't have permission to use.
Can I make some Record Rules for that?
Please help

Аватар
Отменить
Автор Лучший ответ

I managed to do this by modyfing record rule inside Access Rights group for object Companies like this:
[('id', 'in', [c.id for c in user.company_ids])]

​​Now everyone sees only companies that they have in company_ids field.

Аватар
Отменить

You may want to look at the unintended consequences of making this change.

By changing the record rule, as mentioned above, it will result in the user seeing the records for all the companies they have access to in each screen. For example, by default, Odoo displays only the records belonging to the company that is currently active for that user. If you need to see the records of a different company, you have to make it the current company by selecting it from the drop down list on the top right of the screen.

With your new condition, the user will always see the records for all the companies that they have access to, no matter which company is selected as the current company. Is this what you want ?

Автор

Not really. I still see only the records for currently active company.

Лучший ответ

You can add a domain based restriction to the Allowed Companies field on the Users form view (res.users.form) by customizing it (using view inheritance) like so:

https://imgur.com/96EPuji

NOTE: Please ensure that you have added all the companies you/admin need access to before you activate this view. Otherwise the same restriction will apply to your/admin's id too. In any case, you can always disable the view extension if you need to open up access again

Аватар
Отменить
Лучший ответ

I think this app does what you need https://apps.odoo.com/apps/modules/12.0/multicompany_groups/

Аватар
Отменить