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
993 B

  1. # Copyright 2017-2018 Camptocamp - Simone Orsi
  2. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
  3. from odoo import models, fields
  4. class UserNotificationConf(models.Model):
  5. """Hold user's single notification configuration."""
  6. _name = 'user.notification.conf'
  7. _description = 'User notification configuration'
  8. # TODO: add friendly onchange to not yield errors when editin via UI
  9. _sql_constraints = [
  10. ('unique_user_subtype_conf',
  11. 'unique (user_id,subtype_id)',
  12. 'You can have only one configuration per subtype!')
  13. ]
  14. user_id = fields.Many2one(
  15. string='User',
  16. comodel_name='res.users',
  17. readonly=True,
  18. required=True,
  19. ondelete='cascade',
  20. index=True,
  21. )
  22. subtype_id = fields.Many2one(
  23. 'mail.message.subtype',
  24. 'Notification type',
  25. ondelete='cascade',
  26. required=True,
  27. index=True,
  28. )
  29. enabled = fields.Boolean(default=True, index=True)