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
1.2 KiB

  1. # -*- coding: utf-8 -*-
  2. from openerp import models, api
  3. class BaseModelMonkeyPatch(models.AbstractModel):
  4. _name = 'basemodel.monkeypatch'
  5. def _register_hook(self, cr):
  6. if not hasattr(
  7. models.BaseModel, 'base_technical_features_user_has_groups'):
  8. models.BaseModel.base_technical_features_user_has_groups = (
  9. models.BaseModel.user_has_groups)
  10. @api.cr_uid_context
  11. def user_has_groups(self, cr, uid, groups, context=None):
  12. """ Return True for users in the technical features group when
  13. membership of the original group is checked, even if debug mode
  14. is not enabled.
  15. """
  16. if ('base.group_no_one' in groups.split(',') and
  17. self.pool['res.users'].has_group(
  18. cr, uid,
  19. 'base_technical_features.group_technical_features')):
  20. return True
  21. return self.base_technical_features_user_has_groups(
  22. cr, uid, groups, context=context)
  23. models.BaseModel.user_has_groups = user_has_groups
  24. return super(BaseModelMonkeyPatch, self)._register_hook(cr)