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.

76 lines
2.8 KiB

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