Files
tryton/trytond/tests/wizard.py
T

52 lines
1.4 KiB
Python
Raw Normal View History

2014-12-02 12:54:01 +01:00
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
2012-09-24 22:16:53 +02:00
from trytond.model import ModelView, ModelSQL, fields
2012-04-01 23:08:15 +02:00
from trytond.wizard import Wizard, StateView, StateTransition, StateAction, \
Button
2012-01-02 17:48:17 +01:00
from trytond.transaction import Transaction
2011-07-20 19:04:52 +02:00
2012-09-24 22:16:53 +02:00
__all__ = [
'TestWizardStart', 'TestWizard',
]
2011-07-20 19:04:52 +02:00
2012-09-24 22:16:53 +02:00
class TestWizardStart(ModelSQL, ModelView):
'Test Wizard'
__name__ = 'test.test_wizard.start'
2011-07-20 19:04:52 +02:00
name = fields.Char('Test me')
2012-01-02 17:48:17 +01:00
user = fields.Many2One('res.user', 'User')
2014-10-29 20:38:17 +01:00
groups = fields.Many2Many('res.group', None, None, 'Groups')
2011-07-20 19:04:52 +02:00
2012-09-24 22:16:53 +02:00
@staticmethod
def default_user():
2012-01-02 17:48:17 +01:00
return Transaction().user
2011-07-20 19:04:52 +02:00
class TestWizard(Wizard):
2012-09-24 22:16:53 +02:00
'Test Wizard'
__name__ = 'test.test_wizard'
2012-01-02 17:48:17 +01:00
start = StateView('test.test_wizard.start',
2013-09-16 11:38:11 +02:00
'tests.test_wizard_start_view_form', [
2012-01-02 17:48:17 +01:00
Button('Cancel', 'end', 'tryton-cancel'),
Button('Next', 'next_', 'tryton-next', default=True),
])
next_ = StateTransition()
action = StateAction('ir.act_menu_tree')
2012-09-24 22:16:53 +02:00
@staticmethod
def default_start(fields):
2012-01-02 17:48:17 +01:00
return {
'name': 'Test wizard',
}
2012-09-24 22:16:53 +02:00
@staticmethod
def transition_next_():
2012-01-02 17:48:17 +01:00
return 'action'
2012-09-24 22:16:53 +02:00
@staticmethod
def do_action(action):
2012-01-02 17:48:17 +01:00
return action, {}
2012-09-24 22:16:53 +02:00
@staticmethod
def transition_action():
2012-01-02 17:48:17 +01:00
return 'end'