diff --git a/base_kanban_stage_state/models/base_kanban_stage.py b/base_kanban_stage_state/models/base_kanban_stage.py index 446139555..aedc9f153 100644 --- a/base_kanban_stage_state/models/base_kanban_stage.py +++ b/base_kanban_stage_state/models/base_kanban_stage.py @@ -2,19 +2,19 @@ # Copyright 2017 Specialty Medical Drugstore # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -from odoo import fields, models - - -_STATE = [ - ('draft', 'New'), - ('open', 'In Progress'), - ('pending', 'Pending'), - ('done', 'Done'), - ('cancelled', 'Cancelled'), - ('exception', 'Exception')] +from odoo import api, fields, models class BaseKanbanStage(models.Model): _inherit = 'base.kanban.stage' - state = fields.Selection(_STATE, 'State') + @api.model + def _get_states(self): + return [('draft', 'New'), + ('open', 'In Progress'), + ('pending', 'Pending'), + ('done', 'Done'), + ('cancelled', 'Cancelled'), + ('exception', 'Exception')] + + state = fields.Selection(_get_states, 'State') diff --git a/base_kanban_stage_state/tests/__init__.py b/base_kanban_stage_state/tests/__init__.py new file mode 100644 index 000000000..ad0cc73dc --- /dev/null +++ b/base_kanban_stage_state/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Specialty Medical Drugstore +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from . import test_base_kanban_stage diff --git a/base_kanban_stage_state/tests/test_base_kanban_stage.py b/base_kanban_stage_state/tests/test_base_kanban_stage.py new file mode 100644 index 000000000..3cdcc4bb3 --- /dev/null +++ b/base_kanban_stage_state/tests/test_base_kanban_stage.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Specialty Medical Drugstore +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from odoo.tests.common import TransactionCase + + +class TestBaseKanbanStage(TransactionCase): + def test_get_states(self): + '''It should return a list of stages''' + test_stage = self.env['base.kanban.stage'].with_context({}) + + self.assertEqual(test_stage._get_states(), + [('draft', 'New'), + ('open', 'In Progress'), + ('pending', 'Pending'), + ('done', 'Done'), + ('cancelled', 'Cancelled'), + ('exception', 'Exception')] + )