res_users.py 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. # For copyright and license notices, see __openerp__.py file in module root
  4. # directory
  5. ##############################################################################
  6. from openerp import models, fields
  7. class res_users(models.Model):
  8. _inherit = 'res.users'
  9. store_id = fields.Many2one(
  10. 'res.store', 'Store', context={'user_preference': True},
  11. help='The store this user is currently working for.')
  12. store_ids = fields.Many2many(
  13. 'res.store', 'res_store_users_rel', 'user_id', 'cid', 'Stores')
  14. def __init__(self, pool, cr):
  15. """ Override of __init__ to add access rights on
  16. store fields. Access rights are disabled by
  17. default, but allowed on some specific fields defined in
  18. self.SELF_{READ/WRITE}ABLE_FIELDS.
  19. """
  20. init_res = super(res_users, self).__init__(pool, cr)
  21. # duplicate list to avoid modifying the original reference
  22. self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
  23. self.SELF_WRITEABLE_FIELDS.append('store_id')
  24. # duplicate list to avoid modifying the original reference
  25. self.SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
  26. self.SELF_READABLE_FIELDS.append('store_id')
  27. return init_res