Add configuration wizard for res module
- put default action to configuration wizard for user admin - add default value for action/menu
This commit is contained in:
@@ -5,6 +5,7 @@ from xml import dom
|
||||
from xml.dom import minidom
|
||||
from trytond.osv import fields, OSV, ExceptOSV
|
||||
#from trytond.tools import Cache
|
||||
from trytond.wizard import Wizard, WizardOSV
|
||||
|
||||
|
||||
class Group(OSV):
|
||||
@@ -81,6 +82,18 @@ class User(OSV):
|
||||
def default_timezone(self, cursor, user, context=None):
|
||||
return time.tzname[0]
|
||||
|
||||
def default_menu(self, cursor, user, context=None):
|
||||
action_obj = self.pool.get('ir.action')
|
||||
action_ids = action_obj.search(cursor, user, [
|
||||
('usage', '=', 'menu'),
|
||||
], limit=1, context=context)
|
||||
if action_ids:
|
||||
return action_ids[0]
|
||||
return False
|
||||
|
||||
def default_action(self, cursor, user, context=None):
|
||||
return self.default_menu(cursor, user, context=context)
|
||||
|
||||
def __init__(self, pool):
|
||||
super(User, self).__init__(pool)
|
||||
if pool:
|
||||
@@ -215,3 +228,50 @@ class Group2(Group):
|
||||
'res.user', 'res_group_user_rel', 'gid', 'uid', 'Users')
|
||||
|
||||
Group2()
|
||||
|
||||
|
||||
class UserConfigInit(WizardOSV):
|
||||
_name = 'res.user.config.init'
|
||||
|
||||
UserConfigInit()
|
||||
|
||||
|
||||
class UserConfig(Wizard):
|
||||
'Configure users'
|
||||
_name = 'res.user.config'
|
||||
states = {
|
||||
'init': {
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'object': 'res.user.config.init',
|
||||
'state': [
|
||||
('end', 'Cancel', 'gtk-cancel'),
|
||||
('user', 'Ok', 'gtk-ok', True),
|
||||
],
|
||||
},
|
||||
},
|
||||
'user': {
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'object': 'res.user',
|
||||
'state': [
|
||||
('end', 'End', 'gtk-cancel'),
|
||||
('add', 'Add', 'gtk-ok', True),
|
||||
],
|
||||
},
|
||||
},
|
||||
'add': {
|
||||
'result': {
|
||||
'type': 'action',
|
||||
'action': '_add',
|
||||
'state': 'user',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
def _add(self, cursor, user, data, context=None):
|
||||
res_obj = self.pool.get('res.user')
|
||||
res_obj.create(cursor, user, data['form'], context=context)
|
||||
return {'form': {}}
|
||||
|
||||
UserConfig()
|
||||
|
||||
+23
-1
@@ -9,7 +9,7 @@
|
||||
<field name="password">admin</field>
|
||||
<field name="name">Administrator</field>
|
||||
<field name="signature">Administrator</field>
|
||||
<field name="action" ref="ir.act_menu_tree"/>
|
||||
<field name="action" ref="ir.act_module_config_wizard"/>
|
||||
<field name="menu" ref="ir.act_menu_tree"/>
|
||||
<field name="groups" eval="[(6, 0, [ref('group_admin')])]"/>
|
||||
</record>
|
||||
@@ -178,5 +178,27 @@
|
||||
<field name="perm_create" eval="True"/>
|
||||
<field name="perm_unlink" eval="True"/>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="user_config_init_view_form">
|
||||
<field name="model">res.user.config.init</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<form string="Add Users" col="2">
|
||||
<separator string="Add Users" align="0.0" colspan="2"/>
|
||||
<image name="gtk-info"/>
|
||||
<group col="1">
|
||||
<label string="You can now add some users into the system."
|
||||
align="0.0"/>
|
||||
<label string="Be careful that the login must be unique!"
|
||||
align="0.0"/>
|
||||
</group>
|
||||
</form>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.module.module.config_wizard.item"
|
||||
id="config_wizard_item_user">
|
||||
<field name="name">res.user.config</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
||||
Reference in New Issue
Block a user