prototype of configuration wizard
bzr revid: hmo@tinyerp.com-d9d10212c9d6bbb5902436d3bb6fc85005825691
This commit is contained in:
parent
584a0f0d33
commit
24c3169bd7
|
@ -168,5 +168,60 @@
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="view_users_configuration_form">
|
||||||
|
<field name="name">res.users.form</field>
|
||||||
|
<field name="model">res.users</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Configure User">
|
||||||
|
<separator string="Configure User"/>
|
||||||
|
<newline/>
|
||||||
|
<notebook>
|
||||||
|
<page string="User">
|
||||||
|
<field name="name" select="1"/>
|
||||||
|
<field name="active" select="1"/>
|
||||||
|
<field name="login" select="1"/>
|
||||||
|
<field name="password"/>
|
||||||
|
<field name="address_id"/>
|
||||||
|
<field name="company_id" required="1"/>
|
||||||
|
<field name="action_id" required="True"/>
|
||||||
|
<field name="menu_id" domain="[('usage','=','menu')]" required="True"/>
|
||||||
|
<field name="signature" colspan="4"/>
|
||||||
|
<group colspan="4" col="4">
|
||||||
|
<button special="cancel" string="Cancel" />
|
||||||
|
<button name="action_create" type='object' string="Create" />
|
||||||
|
</group>
|
||||||
|
|
||||||
|
</page>
|
||||||
|
<page string="Security">
|
||||||
|
<field name="groups_id" colspan="4"/>
|
||||||
|
<field name="roles_id" colspan="4"/>
|
||||||
|
</page>
|
||||||
|
</notebook>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.actions.act_window" id="action_config_user_form">
|
||||||
|
<field name="name">Configure User</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">res.users</field>
|
||||||
|
<field name="view_type">form</field>
|
||||||
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- register on configuratuion -->
|
||||||
|
<record model="ir.module.module.configuration.step"
|
||||||
|
id="config_wizard_step_user">
|
||||||
|
<field name="name">Configure User</field>
|
||||||
|
<field name="action_id" ref="action_config_user_form"></field>
|
||||||
|
<field name="state">open</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</terp>
|
</terp>
|
||||||
|
|
|
@ -37,6 +37,11 @@ import zipfile
|
||||||
import release
|
import release
|
||||||
import zipimport
|
import zipimport
|
||||||
|
|
||||||
|
import wizard
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ver_regexp = re.compile("^(\\d+)((\\.\\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\\d*)*)(-r(\\d+))?$")
|
ver_regexp = re.compile("^(\\d+)((\\.\\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\\d*)*)(-r(\\d+))?$")
|
||||||
suffix_regexp = re.compile("^(alpha|beta|rc|pre|p)(\\d*)$")
|
suffix_regexp = re.compile("^(alpha|beta|rc|pre|p)(\\d*)$")
|
||||||
|
|
||||||
|
@ -169,7 +174,7 @@ module_repository()
|
||||||
class module_category(osv.osv):
|
class module_category(osv.osv):
|
||||||
_name = "ir.module.category"
|
_name = "ir.module.category"
|
||||||
_description = "Module Category"
|
_description = "Module Category"
|
||||||
|
|
||||||
def _module_nbr(self,cr,uid, ids, prop, unknow_none,context):
|
def _module_nbr(self,cr,uid, ids, prop, unknow_none,context):
|
||||||
cr.execute('select category_id,count(*) from ir_module_module where category_id in ('+','.join(map(str,ids))+') or category_id in (select id from ir_module_category where parent_id in ('+','.join(map(str,ids))+')) group by category_id')
|
cr.execute('select category_id,count(*) from ir_module_module where category_id in ('+','.join(map(str,ids))+') or category_id in (select id from ir_module_category where parent_id in ('+','.join(map(str,ids))+')) group by category_id')
|
||||||
result = dict(cr.fetchall())
|
result = dict(cr.fetchall())
|
||||||
|
@ -178,7 +183,7 @@ class module_category(osv.osv):
|
||||||
childs = [c for c, in cr.fetchall()]
|
childs = [c for c, in cr.fetchall()]
|
||||||
result[id] = reduce(lambda x,y:x+y, [result.get(c, 0) for c in childs], result.get(id, 0))
|
result[id] = reduce(lambda x,y:x+y, [result.get(c, 0) for c in childs], result.get(id, 0))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char("Name", size=128, required=True),
|
'name': fields.char("Name", size=128, required=True),
|
||||||
'parent_id': fields.many2one('ir.module.category', 'Parent Category', select=True),
|
'parent_id': fields.many2one('ir.module.category', 'Parent Category', select=True),
|
||||||
|
@ -240,7 +245,7 @@ class module(osv.osv):
|
||||||
('Other proprietary', 'Other proprietary')], string='License',
|
('Other proprietary', 'Other proprietary')], string='License',
|
||||||
readonly=True),
|
readonly=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'state': lambda *a: 'uninstalled',
|
'state': lambda *a: 'uninstalled',
|
||||||
'demo': lambda *a: False,
|
'demo': lambda *a: False,
|
||||||
|
@ -307,8 +312,8 @@ class module(osv.osv):
|
||||||
for module in self.browse(cr, uid, ids):
|
for module in self.browse(cr, uid, ids):
|
||||||
cr.execute('''select m.state,m.name
|
cr.execute('''select m.state,m.name
|
||||||
from
|
from
|
||||||
ir_module_module_dependency d
|
ir_module_module_dependency d
|
||||||
join
|
join
|
||||||
ir_module_module m on (d.module_id=m.id)
|
ir_module_module m on (d.module_id=m.id)
|
||||||
where
|
where
|
||||||
d.name=%s and
|
d.name=%s and
|
||||||
|
@ -331,7 +336,7 @@ class module(osv.osv):
|
||||||
cr.execute('select code from res_lang where translatable=TRUE')
|
cr.execute('select code from res_lang where translatable=TRUE')
|
||||||
langs = [l[0] for l in cr.fetchall()]
|
langs = [l[0] for l in cr.fetchall()]
|
||||||
modules = self.read(cr, uid, ids, ['name'])
|
modules = self.read(cr, uid, ids, ['name'])
|
||||||
for module in modules:
|
for module in modules:
|
||||||
files = self.get_module_info(module['name']).get('translations', {})
|
files = self.get_module_info(module['name']).get('translations', {})
|
||||||
for lang in langs:
|
for lang in langs:
|
||||||
if files.has_key(lang):
|
if files.has_key(lang):
|
||||||
|
@ -563,3 +568,78 @@ class module_dependency(osv.osv):
|
||||||
}
|
}
|
||||||
module_dependency()
|
module_dependency()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class module_config_wizard_step(osv.osv):
|
||||||
|
_name = 'ir.module.module.configuration.step'
|
||||||
|
|
||||||
|
_columns={
|
||||||
|
'name':fields.char('Name', size=64, required=True, select=True),
|
||||||
|
'action_id':fields.many2one('ir.actions.act_window', 'Action', select=True,required=True, ondelete='cascade'),
|
||||||
|
'sequence':fields.integer('Sequence'),
|
||||||
|
'state':fields.selection([('open', 'Open'),('done', 'Done'),('skip','Skip')], string='State', required=True)
|
||||||
|
}
|
||||||
|
_defaults={
|
||||||
|
'state': lambda *a: 'open',
|
||||||
|
'sequence': lambda *a: 10,
|
||||||
|
}
|
||||||
|
_order="sequence"
|
||||||
|
module_config_wizard_step()
|
||||||
|
|
||||||
|
|
||||||
|
class module_configuration(osv.osv_memory):
|
||||||
|
_name='ir.module.module.configuration.wizard'
|
||||||
|
def _get_wizard(self, cr, uid, context={}):
|
||||||
|
item_obj = self.pool.get('ir.module.module.configuration.step')
|
||||||
|
item_ids = item_obj.search(cr, uid, [
|
||||||
|
('state', '=', 'open'),
|
||||||
|
], limit=1, context=context)
|
||||||
|
if item_ids:
|
||||||
|
item = item_obj.browse(cr, uid, item_ids[0], context=context)
|
||||||
|
return item.id
|
||||||
|
return False
|
||||||
|
|
||||||
|
_columns = {
|
||||||
|
'name': fields.char('Next Wizard', size=64,readonly=True),
|
||||||
|
'item_id':fields.many2one('ir.module.module.configuration.step', 'Next Configuration Wizard', readonly=True,required=True),
|
||||||
|
}
|
||||||
|
_defaults={
|
||||||
|
'item_id':_get_wizard
|
||||||
|
}
|
||||||
|
|
||||||
|
def button_skip(self,cr,uid,ids,context=None):
|
||||||
|
item_obj = self.pool.get('ir.module.module.configuration.step')
|
||||||
|
item_id=self.read(cr,uid,ids)[0]['item_id']
|
||||||
|
if item_id:
|
||||||
|
item = item_obj.browse(cr, uid, item_id, context=context)
|
||||||
|
item_obj.write(cr, uid, item.id, {
|
||||||
|
'state': 'skip',
|
||||||
|
}, context=context)
|
||||||
|
return{
|
||||||
|
'view_type': 'form',
|
||||||
|
'res_model': 'ir.module.module.configuration.wizard',
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'target':'new',
|
||||||
|
}
|
||||||
|
return {}
|
||||||
|
|
||||||
|
def button_continue(self, cr, uid, ids, context=None):
|
||||||
|
item_obj = self.pool.get('ir.module.module.configuration.step')
|
||||||
|
item_id=self.read(cr,uid,ids)[0]['item_id']
|
||||||
|
if item_id:
|
||||||
|
item = item_obj.browse(cr, uid, item_id, context=context)
|
||||||
|
item_obj.write(cr, uid, item.id, {
|
||||||
|
'state': 'done',
|
||||||
|
}, context=context)
|
||||||
|
return{
|
||||||
|
'view_type': item.action_id.view_type,
|
||||||
|
'view_id':item.action_id.view_id and [item.action_id.view_id.id] or False,
|
||||||
|
'res_model': item.action_id.res_model,
|
||||||
|
'type': item.action_id.type,
|
||||||
|
'target':item.action_id.target,
|
||||||
|
}
|
||||||
|
return {}
|
||||||
|
module_configuration()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -200,5 +200,83 @@
|
||||||
id="menu_module_repository_tree"
|
id="menu_module_repository_tree"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="config_wizard_step_view_tree">
|
||||||
|
<field name="model">ir.module.module.configuration.step</field>
|
||||||
|
<field name="type">tree</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree string="Config Wizard Steps" editable="bottom">
|
||||||
|
<field name="name" select="1"/>
|
||||||
|
<field name="action_id" select="1"/>
|
||||||
|
<field name="sequence"/>
|
||||||
|
<field name="state"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.actions.act_window" id="act_config_wizard_step_form">
|
||||||
|
<field name="name">Config Wizard Steps</field>
|
||||||
|
<field name="res_model">ir.module.module.configuration.step</field>
|
||||||
|
<field name="view_id" ref="config_wizard_step_view_tree"/>
|
||||||
|
<field name="view_type">form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<menuitem name="Administration/Modules Management/Config wizard Step"
|
||||||
|
action="act_config_wizard_step_form"
|
||||||
|
id="menu_config_wizard_step_form"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="view_config_wizard_form">
|
||||||
|
<field name="name">Main Configuration wizard</field>
|
||||||
|
<field name="model">ir.module.module.configuration.wizard</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Main Configuration wizard">
|
||||||
|
<separator string="Main Configuration wizard"/>
|
||||||
|
<newline/>
|
||||||
|
<field name="item_id" select="1"/>
|
||||||
|
<group colspan="4" col="4">
|
||||||
|
<button special="cancel" string="Cancel" />
|
||||||
|
<button name="button_skip" type='object' string="Skip" />
|
||||||
|
<button name="button_continue" type='object' string="Continue"/>
|
||||||
|
</group>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.actions.act_window" id="action_config_wizard_form">
|
||||||
|
<field name="name">Main Configuration Window</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">ir.module.module.configuration.wizard</field>
|
||||||
|
<field name="view_type">form</field>
|
||||||
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
name="Administration/Modules Management/Module Configuration"
|
||||||
|
action="action_config_wizard_form" id="menu_config_module"/>
|
||||||
|
|
||||||
|
<!--<record model="ir.module.module.configuration.step"
|
||||||
|
id="config_wizard_item_module">
|
||||||
|
<field name="name">ir.module.module.config</field>
|
||||||
|
<field name="action_id" ref=""/>
|
||||||
|
<field name="sequence" eval="10000"/>
|
||||||
|
<field name="state">open</field>
|
||||||
|
</record>-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</terp>
|
</terp>
|
||||||
|
|
|
@ -55,7 +55,7 @@ view_form = """<?xml version="1.0"?>
|
||||||
class wizard_lang_install(wizard.interface):
|
class wizard_lang_install(wizard.interface):
|
||||||
def _lang_install(self, cr, uid, data, context):
|
def _lang_install(self, cr, uid, data, context):
|
||||||
lang = data['form']['lang']
|
lang = data['form']['lang']
|
||||||
if lang and lang != 'en_EN':
|
if lang and lang != 'en_US':
|
||||||
filename = tools.config["root_path"] + "/i18n/" + lang + ".csv"
|
filename = tools.config["root_path"] + "/i18n/" + lang + ".csv"
|
||||||
tools.trans_load(cr.dbname, filename, lang)
|
tools.trans_load(cr.dbname, filename, lang)
|
||||||
return {}
|
return {}
|
||||||
|
@ -70,7 +70,7 @@ class wizard_lang_install(wizard.interface):
|
||||||
|
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'form', 'arch': view_form, 'fields': fields_form,
|
'result': {'type': 'form', 'arch': view_form, 'fields': fields_form,
|
||||||
'state': [
|
'state': [
|
||||||
('end', 'Cancel', 'gtk-cancel'),
|
('end', 'Cancel', 'gtk-cancel'),
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
import wizard
|
import wizard
|
||||||
import pooler
|
import pooler
|
||||||
|
from wizard import wizard_osv
|
||||||
|
|
||||||
view_form_end = """<?xml version="1.0"?>
|
view_form_end = """<?xml version="1.0"?>
|
||||||
<form string="System upgrade done">
|
<form string="System upgrade done">
|
||||||
|
@ -59,6 +60,11 @@ view_field = {
|
||||||
'readonly': True},
|
'readonly': True},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class module_install_upgrade_start(wizard_osv):
|
||||||
|
_name = 'ir.module.module.install_upgrade.start'
|
||||||
|
|
||||||
|
module_install_upgrade_start()
|
||||||
|
|
||||||
class wizard_info_get(wizard.interface):
|
class wizard_info_get(wizard.interface):
|
||||||
def _get_install(self, cr, uid, data, context):
|
def _get_install(self, cr, uid, data, context):
|
||||||
pool=pooler.get_pool(cr.dbname)
|
pool=pooler.get_pool(cr.dbname)
|
||||||
|
@ -81,9 +87,16 @@ class wizard_info_get(wizard.interface):
|
||||||
db, pool = pooler.restart_pool(cr.dbname, update_module=True)
|
db, pool = pooler.restart_pool(cr.dbname, update_module=True)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
def _config(self, cr, uid, data, context=None):
|
||||||
|
return {
|
||||||
|
'view_type': 'form',
|
||||||
|
'res_model': 'ir.module.module.configuration.wizard',
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
}
|
||||||
|
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [_get_install],
|
'actions': [_get_install],
|
||||||
'result': {'type':'form', 'arch':view_form, 'fields': view_field,
|
'result': {'type':'form', 'arch':view_form, 'fields': view_field,
|
||||||
'state':[
|
'state':[
|
||||||
('end', 'Cancel', 'gtk-cancel'),
|
('end', 'Cancel', 'gtk-cancel'),
|
||||||
|
@ -92,13 +105,47 @@ class wizard_info_get(wizard.interface):
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'start': {
|
'start': {
|
||||||
'actions': [_upgrade_module],
|
'actions': [_upgrade_module],
|
||||||
'result': {'type':'form', 'arch':view_form_end, 'fields': {},
|
'result': {
|
||||||
'state':[
|
'type': 'form',
|
||||||
('end', 'Close', 'gtk-close', True)
|
'object': 'ir.module.module.install_upgrade.start',
|
||||||
]
|
'state': [
|
||||||
}
|
('config', 'Ok', 'tryton-ok', True),
|
||||||
},
|
],
|
||||||
}
|
},
|
||||||
|
},
|
||||||
|
'config': {
|
||||||
|
'result': {
|
||||||
|
'type': 'action',
|
||||||
|
'action': _config,
|
||||||
|
'state': 'end',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
wizard_info_get('module.upgrade')
|
wizard_info_get('module.upgrade')
|
||||||
|
|
||||||
|
class module_config(wizard.interface):
|
||||||
|
def _action_open(self, cr, uid, datas, context=None):
|
||||||
|
pool=pooler.get_pool(cr.dbname)
|
||||||
|
model_data_obj = pool.get('ir.model.data')
|
||||||
|
act_window_obj = pool.get('ir.actions.act_window')
|
||||||
|
model_data_ids = model_data_obj.search(cr, uid, [
|
||||||
|
('name', '=', 'open_module_tree'),
|
||||||
|
('module', '=', 'base'),
|
||||||
|
], limit=1, context=context)
|
||||||
|
model_data = model_data_obj.browse(cr, uid, model_data_ids[0],
|
||||||
|
context=context)
|
||||||
|
res = act_window_obj.read(cr, uid, model_data.res_id, context=context)
|
||||||
|
return res
|
||||||
|
states = {
|
||||||
|
'init': {
|
||||||
|
'result': {
|
||||||
|
'type': 'action',
|
||||||
|
'action': _action_open,
|
||||||
|
'state': 'end',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
module_config('ir.module.module.config')
|
||||||
|
|
|
@ -150,7 +150,7 @@ class users(osv.osv):
|
||||||
if 1 in ids:
|
if 1 in ids:
|
||||||
raise osv.except_osv('Can not remove root user !', 'You can not remove the root user as it is used internally for resources created by Tiny ERP (updates, module installation, ...)')
|
raise osv.except_osv('Can not remove root user !', 'You can not remove the root user as it is used internally for resources created by Tiny ERP (updates, module installation, ...)')
|
||||||
return super(users, self).unlink(cr, uid, ids)
|
return super(users, self).unlink(cr, uid, ids)
|
||||||
|
|
||||||
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=80):
|
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=80):
|
||||||
if not args:
|
if not args:
|
||||||
args=[]
|
args=[]
|
||||||
|
@ -162,7 +162,7 @@ class users(osv.osv):
|
||||||
if not ids:
|
if not ids:
|
||||||
ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit)
|
ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit)
|
||||||
return self.name_get(cr, user, ids)
|
return self.name_get(cr, user, ids)
|
||||||
|
|
||||||
def copy(self, cr, uid, id, default=None, context={}):
|
def copy(self, cr, uid, id, default=None, context={}):
|
||||||
login = self.read(cr, uid, [id], ['login'])[0]['login']
|
login = self.read(cr, uid, [id], ['login'])[0]['login']
|
||||||
default.update({'login': login+' (copy)'})
|
default.update({'login': login+' (copy)'})
|
||||||
|
@ -180,6 +180,14 @@ class users(osv.osv):
|
||||||
dataobj = self.pool.get('ir.model.data')
|
dataobj = self.pool.get('ir.model.data')
|
||||||
data_id = dataobj._get_id(cr, 1, 'base', 'action_res_users_my')
|
data_id = dataobj._get_id(cr, 1, 'base', 'action_res_users_my')
|
||||||
return dataobj.browse(cr, uid, data_id, context).res_id
|
return dataobj.browse(cr, uid, data_id, context).res_id
|
||||||
|
|
||||||
|
def action_create(self,cr,uid,ids,context={}):
|
||||||
|
return {
|
||||||
|
'view_type': 'form',
|
||||||
|
'res_model': 'ir.module.module.configuration.wizard',
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'target':'new',
|
||||||
|
}
|
||||||
users()
|
users()
|
||||||
|
|
||||||
class groups2(osv.osv):
|
class groups2(osv.osv):
|
||||||
|
|
Loading…
Reference in New Issue