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.

83 lines
3.1 KiB

  1. # Copyright 2016 LasLabs Inc.
  2. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
  3. from odoo import api, fields, models
  4. class BaseKanbanStage(models.Model):
  5. _name = 'base.kanban.stage'
  6. _description = 'Kanban Stage'
  7. _order = 'res_model_id, sequence'
  8. name = fields.Char(
  9. string='Stage Name',
  10. translate=True,
  11. required=True,
  12. help='Displayed as the header for this stage in Kanban views',
  13. )
  14. description = fields.Text(
  15. translate=True,
  16. help='Short description of the stage\'s meaning/purpose',
  17. )
  18. sequence = fields.Integer(
  19. default=1,
  20. required=True,
  21. index=True,
  22. help='Order of stage in relation to other stages available for the'
  23. ' same model',
  24. )
  25. legend_priority = fields.Text(
  26. string='Priority Explanation',
  27. translate=True,
  28. default='Mark a card as medium or high priority (one or two stars) to'
  29. ' indicate that it should be escalated ahead of others with'
  30. ' lower priority/star counts.',
  31. help='Explanation text to help users understand how the priority/star'
  32. ' mechanism applies to this stage',
  33. )
  34. legend_blocked = fields.Text(
  35. string='Special Handling Explanation',
  36. translate=True,
  37. default='Give a card the special handling status to indicate that it'
  38. ' requires handling by a special user or subset of users.',
  39. help='Explanation text to help users understand how the special'
  40. ' handling status applies to this stage',
  41. )
  42. legend_done = fields.Text(
  43. string='Ready Explanation',
  44. translate=True,
  45. default='Mark a card as ready when it has been fully processed.',
  46. help='Explanation text to help users understand how the ready status'
  47. ' applies to this stage',
  48. )
  49. legend_normal = fields.Text(
  50. string='Normal Handling Explanation',
  51. translate=True,
  52. default='This is the default status and indicates that a card can be'
  53. ' processed by any user working this queue.',
  54. help='Explanation text to help users understand how the normal'
  55. ' handling status applies to this stage',
  56. )
  57. fold = fields.Boolean(
  58. string='Collapse?',
  59. help='Determines whether this stage will be collapsed down in Kanban'
  60. ' views',
  61. )
  62. res_model_id = fields.Many2one(
  63. string='Associated Model',
  64. comodel_name='ir.model',
  65. required=True,
  66. index=True,
  67. help='The model that this Kanban stage will be used for',
  68. domain=[('transient', '=', False)],
  69. default=lambda s: s._default_res_model_id(),
  70. )
  71. @api.model
  72. def _default_res_model_id(self):
  73. '''Useful when creating stages from a Kanban view for another model'''
  74. action_id = self.env.context.get('params', {}).get('action')
  75. action = self.env['ir.actions.act_window'].browse(action_id)
  76. default_model = action.res_model
  77. if default_model != self._name:
  78. return self.env['ir.model'].search([('model', '=', default_model)])