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.

31 lines
949 B

  1. # -*- coding: utf-8 -*-
  2. # © 2016 Camptocamp SA
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
  4. from openerp 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. try:
  18. self.check_access_rule(operation)
  19. except exceptions.AccessError:
  20. result[operation] = False
  21. else:
  22. result[operation] = True
  23. return result
  24. models.BaseModel.check_access_rule_all = check_access_rule_all