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.

33 lines
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2016 Opener B.V. (<https://opener.am>)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp import models, api
  5. class BaseModelMonkeyPatch(models.AbstractModel):
  6. _name = 'basemodel.monkeypatch'
  7. def _register_hook(self, cr):
  8. if not hasattr(
  9. models.BaseModel, 'base_technical_features_user_has_groups'):
  10. models.BaseModel.base_technical_features_user_has_groups = (
  11. models.BaseModel.user_has_groups)
  12. @api.cr_uid_context
  13. def user_has_groups(self, cr, uid, groups, context=None):
  14. """ Return True for users in the technical features group when
  15. membership of the original group is checked, even if debug mode
  16. is not enabled.
  17. """
  18. if ('base.group_no_one' in groups.split(',') and
  19. self.pool['res.users'].has_group(
  20. cr, uid,
  21. 'base_technical_features.group_technical_features')):
  22. return True
  23. return self.base_technical_features_user_has_groups(
  24. cr, uid, groups, context=context)
  25. models.BaseModel.user_has_groups = user_has_groups
  26. return super(BaseModelMonkeyPatch, self)._register_hook(cr)