Add framework to handle configuration wizard
- One object where module subscribe the configuration wizards - One wizard that loop throw all the open configuration wizards
This commit is contained in:
1 parent
1fa0da7d6a
commit
4548d73047
2 files changed
+146
No files matched your search
@@ -449,6 +449,102 @@ class ModuleDependency(OSV):
|
||||
ModuleDependency()
|
||||
|
||||
|
||||
class ModuleConfigWizardItem(OSV):
|
||||
"Config wizard to run after installing module"
|
||||
_name = 'ir.module.module.config_wizard.item'
|
||||
_description = __doc__
|
||||
name = fields.Char('Name', size=64, required=True, readonly=True)
|
||||
sequence= fields.Integer('Sequence')
|
||||
state = fields.Selection([
|
||||
('open', 'Open'),
|
||||
('done', 'Done'),
|
||||
], string='State', required=True)
|
||||
_order = 'sequence'
|
||||
|
||||
def default_state(self, cursor, user, context=None):
|
||||
return 'open'
|
||||
|
||||
def default_sequence(self, cursor, user, context=None):
|
||||
return 10
|
||||
|
||||
ModuleConfigWizardItem()
|
||||
|
||||
|
||||
class ModuleConfigWizardFirst(WizardOSV):
|
||||
_name = 'ir.module.module.config_wizard.first'
|
||||
|
||||
ModuleConfigWizardFirst()
|
||||
|
||||
|
||||
class ModuleConfigWizard(Wizard):
|
||||
'Run config wizards'
|
||||
_name = 'ir.module.module.config_wizard'
|
||||
states = {
|
||||
'init': {
|
||||
'result': {
|
||||
'type': 'choice',
|
||||
'next_state': '_first',
|
||||
},
|
||||
},
|
||||
'first': {
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'object': 'ir.module.module.config_wizard.first',
|
||||
'state': [
|
||||
('end', 'Cancel', 'gtk-cancel'),
|
||||
('wizard', 'Ok', 'gtk-ok', True),
|
||||
],
|
||||
},
|
||||
},
|
||||
'wizard': {
|
||||
'result': {
|
||||
'type': 'action',
|
||||
'action': '_action_wizard',
|
||||
'state': 'next',
|
||||
},
|
||||
},
|
||||
'next': {
|
||||
'result': {
|
||||
'type': 'choice',
|
||||
'next_state': '_next',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
def _first(self, cursor, user, data, context=None):
|
||||
res = self._next(cursor, user, data, context=context)
|
||||
if res == 'wizard':
|
||||
return 'first'
|
||||
return res
|
||||
|
||||
def _action_wizard(self, cursor, user, data, context=None):
|
||||
item_obj = self.pool.get('ir.module.module.config_wizard.item')
|
||||
item_ids = item_obj.search(cursor, user, [
|
||||
('state', '=', 'open'),
|
||||
], limit=1, context=context)
|
||||
if item_ids:
|
||||
item = item_obj.browse(cursor, user, item_ids[0], context=context)
|
||||
item_obj.write(cursor, user, item.id, {
|
||||
'state': 'done',
|
||||
}, context=context)
|
||||
return {
|
||||
'type': 'ir.action.wizard',
|
||||
'wiz_name': item.name,
|
||||
}
|
||||
return {}
|
||||
|
||||
def _next(self, cursor, user, data, context=None):
|
||||
item_obj = self.pool.get('ir.module.module.config_wizard.item')
|
||||
item_ids = item_obj.search(cursor, user, [
|
||||
('state', '=', 'open'),
|
||||
], context=context)
|
||||
if item_ids:
|
||||
return 'wizard'
|
||||
return 'end'
|
||||
|
||||
ModuleConfigWizard()
|
||||
|
||||
|
||||
class ModuleUpdateListInit(WizardOSV):
|
||||
_name = 'ir.module.module.update_list.init'
|
||||
|
||||
|
||||
@@ -104,6 +104,56 @@
|
||||
</record>
|
||||
<menuitem parent="menu_modules"
|
||||
action="act_module_form" id="menu_module_form"/>
|
||||
<record model="ir.ui.view" id="config_wizard_item_view_tree">
|
||||
<field name="model">ir.module.module.config_wizard.item</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<tree string="Config Wizard Items" editable="bottom">
|
||||
<field name="name"/>
|
||||
<field name="sequence"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window" id="act_config_wizard_item_form">
|
||||
<field name="name">Config Wizard Items</field>
|
||||
<field name="res_model">ir.module.module.config_wizard.item</field>
|
||||
<field name="view_type">form</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view"
|
||||
id="act_config_wizard_item_form_view1">
|
||||
<field name="sequence" eval="10"/>
|
||||
<field name="view" ref="config_wizard_item_view_tree"/>
|
||||
<field name="act_window" ref="act_config_wizard_item_form"/>
|
||||
</record>
|
||||
<menuitem parent="menu_modules"
|
||||
action="act_config_wizard_item_form"
|
||||
id="menu_config_wizard_item_form"/>
|
||||
<record model="ir.action.wizard" id="act_module_config_wizard">
|
||||
<field name="name">Module Configuration</field>
|
||||
<field name="wiz_name">ir.module.module.config_wizard</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="module_config_wizard_first_view_form">
|
||||
<field name="model">ir.module.module.config_wizard.first</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<form string="Module Configuration Wizard" col="2">
|
||||
<separator string="Welcome to the module configuration wizard!"
|
||||
align="0.0" colspan="2"/>
|
||||
<image name="gtk-info"/>
|
||||
<group col="1">
|
||||
<label string="You will be able to configure your installation"
|
||||
align="0.0"/>
|
||||
<label string="depending on the modules you have installed."
|
||||
align="0.0"/>
|
||||
</group>
|
||||
</form>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="act_module_update_list">
|
||||
<field name="name">Update Module List</field>
|
||||
<field name="wiz_name">ir.module.module.update_list</field>
|
||||
|
||||
Reference in new issue
Block a user