diff options
| author | Martin Trigaux <mat@odoo.com> | 2020-01-14 10:47:08 +0100 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2020-02-04 17:53:48 +0100 |
| commit | c6f24da3f27cd715cc1e8fec9070db71ce5885c5 (patch) | |
| tree | baf466d03acb3d6c134548fafcd2735b9211e2bf /odoo/addons/base | |
| parent | 6d8688bb124df311648f65f6d43608ee22d5f63b (diff) | |
[IMP] base: do not load actions when can not read target models
As neither fields_view_get, nor default_get actually verify you have
access to a specific model (this is likely to be changed in the
future), it was possible to execute an action to a model, even if the
user does not have access to the corresponding model.
Before this commit, launching an action to a wizard with no access was
opening a new record view with all fields in readonly and clicking on
any button raised an access error.
To avoid the frustrating of seeing an action but getting an unusable
screen when clicking on it, just hide the action in the first place.
Diffstat (limited to 'odoo/addons/base')
| -rw-r--r-- | odoo/addons/base/models/ir_actions.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/odoo/addons/base/models/ir_actions.py b/odoo/addons/base/models/ir_actions.py index 8f2d289fbed..1b3916c8d56 100644 --- a/odoo/addons/base/models/ir_actions.py +++ b/odoo/addons/base/models/ir_actions.py @@ -109,6 +109,7 @@ class IrActions(models.Model): WHERE a.binding_model_id=m.id AND m.model=%s ORDER BY a.id """ cr.execute(query, [model_name]) + IrModelAccess = self.env['ir.model.access'] # discard unauthorized actions, and read action definitions result = defaultdict(list) @@ -117,9 +118,13 @@ class IrActions(models.Model): try: action = self.env[action_model].browse(action_id) action_groups = getattr(action, 'groups_id', ()) + action_model = getattr(action, 'res_model', False) if action_groups and not action_groups & user_groups: # the user may not perform this action continue + if action_model and not IrModelAccess.check(action_model, mode='read', raise_exception=False): + # the user won't be able to read records + continue result[binding_type].append(action.read()[0]) except (AccessError, MissingError): continue |
