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.

69 lines
2.6 KiB

  1. ###################################################################################
  2. #
  3. # Copyright (C) 2018 MuK IT GmbH
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU Affero General Public License as
  7. # published by the Free Software Foundation, either version 3 of the
  8. # License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU Affero General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #
  18. ###################################################################################
  19. from odoo import models, fields, api
  20. class ResUsers(models.Model):
  21. _inherit = 'res.users'
  22. #----------------------------------------------------------
  23. # Defaults
  24. #----------------------------------------------------------
  25. @api.model
  26. def _default_sidebar_type(self):
  27. return self.env.user.company_id.default_sidebar_preference or 'small'
  28. @api.model
  29. def _default_chatter_position(self):
  30. return self.env.user.company_id.default_chatter_preference or 'sided'
  31. #----------------------------------------------------------
  32. # Database
  33. #----------------------------------------------------------
  34. sidebar_type = fields.Selection(
  35. selection=[
  36. ('invisible', 'Invisible'),
  37. ('small', 'Small'),
  38. ('large', 'Large')
  39. ],
  40. required=True,
  41. string="Sidebar Type",
  42. default=lambda self: self._default_sidebar_type())
  43. chatter_position = fields.Selection(
  44. selection=[
  45. ('normal', 'Normal'),
  46. ('sided', 'Sided'),
  47. ],
  48. required=True,
  49. string="Chatter Position",
  50. default=lambda self: self._default_chatter_position())
  51. def __init__(self, pool, cr):
  52. init_res = super(ResUsers, self).__init__(pool, cr)
  53. type(self).SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
  54. type(self).SELF_WRITEABLE_FIELDS.extend(['sidebar_type'])
  55. type(self).SELF_WRITEABLE_FIELDS.extend(['chatter_position'])
  56. type(self).SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
  57. type(self).SELF_READABLE_FIELDS.extend(['sidebar_type'])
  58. type(self).SELF_READABLE_FIELDS.extend(['chatter_position'])
  59. return init_res