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.

84 lines
3.1 KiB

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