Repository navigation
[18.0][ADD] operating_unit_window_action_isolation - #888
luc-demeyer wants to merge 5 commits into
Conversation
The commit removes the dependency on 'sale_operating_unit', which was only required for the unit tests. The unit tests have been moved to a new module, operating_unit_window_action_isolation_sale.
Replace is_superuser() with uid == SUPERUSER_ID so that sudo() calls do not bypass the operating unit domain filter. The standard Odoo web client loads menu actions via _get_action_dict() (cf. ir_actions.py) which calls self.sudo().read(), causing is_superuser() to return True for every regular user and effectively disabling the filter for all users.
| """Restrict actions to the user's default operating unit.""" | ||
| result = super().read(fields=fields, load=load) | ||
|
|
||
| if self.env.uid == SUPERUSER_ID: |
There was a problem hiding this comment.
Can we use self.env.is_superuser() ?
self.env.is_superuser() and self.env.uid == SUPERUSER_ID is same right ?
There was a problem hiding this comment.
@LINTOANTONY007
it's completely different, cf. https://github.com/odoo/odoo/blob/df75d96296953382f277d6bdbe5fc703c7c717a1/odoo/api.py#L672
Have also a look to my commit message ed51858. This explains why the is_superuser() broke the functionality offered by the originating Odoo 13.0 module.
In Odoo 13.0 we also have
self.env.uid != SUPERUSER_ID
cf. https://github.com/sj3/canna-third-party/blob/e7b7bbf84c90d80f400b7a5b68fd081d95b78bef/operating_unit_window_action_isolation/models/ir_actions_act_window.py#L18
It's not clear to me why https://github.com/sj-onestein-nl has added this line in the code when creating the original module. I assume it was required to prevent a failing pipeline. Imho we can leave this SUPERUSER_ID exclusion in the code for the time being.
There was a problem hiding this comment.
Yeah you are right. As noted in the commit, is_superuser() checks whether the environment is in superuser mode, not if the user itself is a superuser.
|
This PR has the |
24bbf2d to
d8a8777
Compare
|
@LINTOANTONY007 @ByteMeAsap |
…omain Replace direct access to user.default_operating_unit_id with res.users,_get_default_operating_unit() so that the upcoming cookie-based session OU takes priority (cf. OCA#891).
d8a8777 to
5052ee0
Compare
|
@LINTOANTONY007 cf. ir_actions_act_window.py: |
This PR is based upon #858 but with two changes
remove sale_operating_unit dependency
This depends was added for unit tests based upon the sale.order window action.
I moved the unit tests to a seperate module so that the depends becomes clean
bug fix (cf. commit ed51858)
With this the module works correctly for 'single operating unit' users.
But in reality this module is intended for 'multi operating unit' users and requires the prerequisite 'web_easy_switch_operating_unit" module, cf. #853.
PR 853 got closed since it has been marked as stale and closed automatically afterwards.
I'll pick this work test it and make a new PR for this module.
After merging this one, we should imho add the web_easy_switch_operating_unit to the dependencies of the operating_unit_window_action_isolation.
FYI:
These modules are coming from https://github.com/sj3/canna-third-party.