Browse Source

Merge pull request #316 from guewen/fix-web_access_rule_buttons-transient

[9.0] web_access_rule_buttons: Skip check on TransientModels without ID
pull/322/head
Holger Brunn 9 years ago
parent
commit
3199103fb0
  1. 6
      web_access_rule_buttons/models.py

6
web_access_rule_buttons/models.py

@ -19,6 +19,12 @@ def check_access_rule_all(self, operations=None):
operations = ['read', 'create', 'write', 'unlink'] operations = ['read', 'create', 'write', 'unlink']
result = {} result = {}
for operation in operations: for operation in operations:
if self.is_transient() and not self.ids:
# If we call check_access_rule() without id, it will try to run a
# SELECT without ID which will crash, so we just blindly allow the
# operations
result[operation] = True
continue
try: try:
self.check_access_rule(operation) self.check_access_rule(operation)
except exceptions.AccessError: except exceptions.AccessError:

Loading…
Cancel
Save