You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.2 KiB

Skip check on TransientModels without ID Fix: Traceback (most recent call last): File "/opt/odoo/src/openerp/http.py", line 643, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/opt/odoo/src/openerp/http.py", line 680, in dispatch result = self._call_function(**self.params) File "/opt/odoo/src/openerp/http.py", line 316, in _call_function return checked_call(self.db, *args, **kwargs) File "/opt/odoo/src/openerp/service/model.py", line 118, in wrapper return f(dbname, *args, **kwargs) File "/opt/odoo/src/openerp/http.py", line 309, in checked_call result = self.endpoint(*a, **kw) File "/opt/odoo/src/openerp/http.py", line 959, in __call__ return self.method(*args, **kw) File "/opt/odoo/src/openerp/http.py", line 509, in response_wrap response = f(*args, **kw) File "/opt/odoo/src/addons/web/controllers/main.py", line 893, in call_kw return self._call_kw(model, method, args, kwargs) File "/opt/odoo/src/addons/web/controllers/main.py", line 885, in _call_kw return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) File "/opt/odoo/src/openerp/api.py", line 250, in wrapper return old_api(self, *args, **kwargs) File "/opt/odoo/src/openerp/api.py", line 381, in old_api result = method(recs, *args, **kwargs) File "/opt/odoo/external-src/web/web_access_rule_buttons/models.py", line 24, in check_access_rule_all result[operation] = True File "/opt/odoo/src/openerp/api.py", line 248, in wrapper return new_api(self, *args, **kwargs) File "/opt/odoo/src/openerp/api.py", line 574, in new_api result = method(self._model, cr, uid, self.ids, *args, **old_kwargs) File "/opt/odoo/src/openerp/models.py", line 3554, in check_access_rule WHERE id IN %%s""" % self._table, (tuple(ids),)) File "/opt/odoo/src/openerp/sql_db.py", line 139, in wrapper return f(self, *args, **kwargs) File "/opt/odoo/src/openerp/sql_db.py", line 218, in execute res = self._obj.execute(query, params) ProgrammingError: syntax error at or near ")" LINE 3: WHERE id IN ()
9 years ago
  1. # -*- coding: utf-8 -*-
  2. # © 2016 Camptocamp SA
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
  4. from odoo import models, api, exceptions
  5. @api.multi
  6. def check_access_rule_all(self, operations=None):
  7. """Verifies that the operation given by ``operations`` is allowed for the
  8. user according to ir.rules.
  9. If ``operations`` is empty, it returns the result for all actions.
  10. :param operation: a list of ``read``, ``create``, ``write``, ``unlink``
  11. :return: {operation: access} (access is a boolean)
  12. """
  13. if operations is None:
  14. operations = ['read', 'create', 'write', 'unlink']
  15. result = {}
  16. for operation in operations:
  17. if self.is_transient() and not self.ids:
  18. # If we call check_access_rule() without id, it will try to run a
  19. # SELECT without ID which will crash, so we just blindly allow the
  20. # operations
  21. result[operation] = True
  22. continue
  23. try:
  24. self.check_access_rule(operation)
  25. except exceptions.AccessError:
  26. result[operation] = False
  27. else:
  28. result[operation] = True
  29. return result
  30. models.BaseModel.check_access_rule_all = check_access_rule_all