[IMP] remove add more features wizard -> will be replaced by kanban on modules and homepage

bzr revid: fp@tinyerp.com-20111206161311-99dpd7t69c108q6u
This commit is contained in:
Fabien Pinckaers 2011-12-06 17:13:11 +01:00
parent 89173c80be
commit fb0b22ecd4
2 changed files with 0 additions and 314 deletions

View File

@ -28,290 +28,6 @@ from osv import fields, osv
from tools.translate import _
from lxml import etree
#Application and feature chooser, this could be done by introspecting ir.modules
DEFAULT_MODULES = {
'Customer Relationship Management' : ['crm',],
'Sales Management' : ['sale',],
'Project Management' : ['project',],
'Knowledge Management' : ['document',],
'Warehouse Management' : ['stock',],
'Manufacturing' : ['mrp'],
'Accounting & Finance' : ['account'],
'Purchase Management' : ['purchase'],
'Human Resources' : ['hr',],
'Point of Sale' : ['point_of_sale',],
'Marketing' : ['marketing',],
}
class base_setup_installer(osv.osv_memory):
_name = 'base.setup.installer'
_inherit = 'res.config.installer'
_columns = {
'selection' : fields.text('Selection'),
}
def fields_get(self, cr, uid, fields=None, context=None):
if context is None:
context = {}
if fields is None:
fields = {}
fields = {}
category_proxy = self.pool.get('ir.module.category')
domain = [('parent_id', '=', False),
('name', '!=', 'Uncategorized'),
('visible', '=', True)]
category_ids = category_proxy.search(cr, uid, domain, context=context)
for category in category_proxy.browse(cr, uid, category_ids, context=context):
category_name = 'category_%d' % (category.id,)
fields[category_name] = {
'type' : 'boolean',
'string' : category.name,
'name' : category_name,
'help' : category.description,
}
module_proxy = self.pool.get('ir.module.module')
module_ids = module_proxy.search(cr, uid, [], context=context)
for module in module_proxy.browse(cr, uid, module_ids, context=context):
module_name = 'module_%d' % (module.id,)
module_is_installed = module.state == 'installed'
fields[module_name] = {
'type' : 'boolean',
'string' : module.shortdesc,
'name' : module_name,
'help' : module.description,
}
return fields
def default_get(self, cr, uid, fields=None, context=None):
if context is None:
context = {}
if fields is None:
fields = {}
result = {}
if 'dont_compute_virtual_attributes' not in context:
module_proxy = self.pool.get('ir.module.module')
module_ids = module_proxy.search(cr, uid, [], context=context)
for module in module_proxy.browse(cr, uid, module_ids, context=context):
result['module_%d' % (module.id,)] = module.state == 'installed'
cat_proxy = self.pool.get('ir.module.category')
cat_ids = cat_proxy.search(cr, uid, [], context=context)
for cat in cat_proxy.browse(cr, uid, cat_ids, context=context):
m = DEFAULT_MODULES.get(cat.name,[])
r = module_proxy.search(cr, uid, [('state','=','installed'),('name','in',m)])
result['category_%d' % (cat.id,)] = bool(r) and (len(r) == len(m))
return result
def fields_view_get(self, cr, uid, view_id=None, view_type='from', context=None, toolbar=False, submenu=False):
def in_extended_view_group(cr, uid, context=None):
try:
model, group_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base', 'group_extended')
except ValueError:
return False
return group_id in self.pool.get('res.users').read(cr, uid, uid, ['groups_id'], context=context)['groups_id']
result = super(base_setup_installer, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
module_category_proxy = self.pool.get('ir.module.category')
domain = [('parent_id', '=', False),
('name', '!=', 'Uncategorized'),
('visible', '=', True)]
module_category_ids = module_category_proxy.search(cr, uid, domain, context=context, order='sequence asc')
arch = ['<form string="%s">' % _('Automatic Base Setup')]
arch.append('<separator string="%s" colspan="4" />' % _('Install Applications'))
module_proxy = self.pool.get('ir.module.module')
extended_view = in_extended_view_group(cr, uid, context=context)
for module_category in module_category_proxy.browse(cr, uid, module_category_ids, context=context):
domain = [('category_id', '=', module_category.id)]
if not extended_view:
domain.append(('complexity', '!=', 'expert'))
modules = module_proxy.browse(cr, uid, module_proxy.search(cr, uid, domain, context=context), context=context)
if not modules:
continue
m = DEFAULT_MODULES.get(module_category.name, [])
r = module_proxy.search(cr, uid, [('state', '=', 'installed'),('name', 'in', m)], context=context)
readonly = bool(r)
attributes = {
'name' : 'category_%d' % (module_category.id,),
'on_change' : 'on_change_%s_%d(category_%d)' % ('category', module_category.id, module_category.id,),
}
if readonly:
attributes['modifiers'] = simplejson.dumps({'readonly' : True})
arch.append("""<field %s />""" % (" ".join(["%s='%s'" % (key, value,)
for key, value in attributes.iteritems()]),))
# Compute the modules to show
for module_category in module_category_proxy.browse(cr, uid, module_category_ids, context=context):
domain = [('category_id', '=', module_category.id)]
if not extended_view:
domain.append(('complexity', '!=', 'expert'))
default_modules = DEFAULT_MODULES.get(module_category.name, False)
if default_modules:
domain.append(('name', 'not in', default_modules))
modules = module_proxy.browse(cr, uid, module_proxy.search(cr, uid, domain, context=context), context=context)
if not modules:
continue
modifiers = {
'invisible' : [('category_%d' % (module_category.id), '=', False)],
}
module_modifiers = dict(modifiers)
arch.append("""<separator string="%s Features" colspan="4" modifiers='%s'/>""" % (
cgi.escape(module_category.name),
simplejson.dumps(modifiers))
)
for module in modules:
#module_modifiers['readonly'] = module.state == 'installed'
arch.append("""<field name="module_%d" modifiers='%s' />""" % (
module.id,
simplejson.dumps(module_modifiers))
)
arch.append(
'<separator colspan="4" />'
'<group colspan="4" col="2">'
'<button special="cancel" string="Cancel" icon="gtk-cancel" />'
'<button string="Install Modules" type="object" name="apply_cb" icon="gtk-apply" />'
'</group>'
)
arch.append('</form>')
result['arch'] = ''.join(arch)
return result
def __getattr__(self, name):
if name.startswith('on_change_category_'):
def proxy(cr, uid, ids, value, context=None):
item = 'category_%s' % name[len('on_change_category_'):]
return self._on_change_selection(cr, uid, ids, item, value, context=context)
return proxy
return getattr(super(base_setup_installer, self), name)
def _on_change_selection(self, cr, uid, ids, item, value, context=None):
if not isinstance(item, basestring) or not value:
return {}
if item.startswith('category_') or item.startswith('module_'):
object_name, identifier = item.split('_')
else:
return {}
values = {
}
#if object_name == 'category':
# module_ids = self.pool.get('ir.module.module').search(cr, uid, [('category_id', '=', int(identifier))], context=context)
# for module_id in module_ids:
# values['module_%d' % module_id] = 1
return {'value': values}
def create(self, cr, uid, values, context=None):
to_install = {'categories' : [], 'modules' : []}
for key, value in values.iteritems():
if value == 1 and (key.startswith('module_') or key.startswith('category_')):
kind, identifier = key.split('_')
if kind == 'category':
to_install['categories'].append(long(identifier))
if kind == 'module':
to_install['modules'].append(long(identifier))
values = {
'selection' : simplejson.dumps(to_install),
}
context.update(dont_compute_virtual_attributes=True)
return super(base_setup_installer, self).create(cr, uid, values, context=context)
def apply_cb(self, cr, uid, ids, context=None):
category_proxy = self.pool.get('ir.module.category')
for installer in self.browse(cr, uid, ids, context=context):
to_install = simplejson.loads(installer.selection)
proxy = self.pool.get('ir.module.module')
module_ids = proxy.search(cr, uid, [('id', 'in', to_install['modules'])], context=context)
modules = set(record['name']
for record in proxy.read(cr, uid, module_ids, ['name'], context=context))
category_ids = category_proxy.search(cr, uid, [('id', 'in', to_install['categories'])], context=context)
selected_categories = set(record['name']
for record in category_proxy.read(cr, uid, category_ids, ['name'], context=context))
# FIXME: Use a workaround, but can do better
for category_name, default_modules in DEFAULT_MODULES.iteritems():
if category_name in selected_categories:
modules.update(default_modules)
# Special Cases:
# * project_mrp: the dependencies are sale, project, procurement, mrp_jit
if 'sale' in modules and 'project' in modules:
modules.add('project_mrp')
need_update = False
module_ids = proxy.search(cr, uid, [('name', 'in', list(modules))], context=context)
if module_ids:
proxy.state_update(cr, uid, module_ids, 'to install', ['uninstalled'], context=context)
need_update = True
category_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base', 'module_category_hidden_link')
while True and category_id:
cr.execute("select id, name from ir_module_module m where category_id = %s \
and (select count(d.id) from ir_module_module_dependency d \
where d.module_id = m.id) = (select count(d.id) from \
ir_module_module_dependency d inner join ir_module_module m2 on d.name = m2.name \
where d.module_id=m.id and m2.state in %s ) and state = %s",
(category_id[1], ('installed', 'to install', 'to upgrade', ), 'uninstalled',))
inner_modules = [name for _, name in cr.fetchall()]
module_ids = proxy.search(cr, uid, [('name', 'in', inner_modules)], context=context)
if not module_ids:
break
modules.update(inner_modules)
proxy.state_update(cr, uid, module_ids, 'to install', ['uninstalled'], context=context)
need_update = True
domain = [('name', 'in', list(modules)),
('state', '=', 'installed')]
for module in proxy.browse(cr, uid, proxy.search(cr, uid, domain, context=context), context):
cr.execute("update ir_actions_todo set state='open' \
from ir_model_data as data where data.res_id = ir_actions_todo.id \
and ir_actions_todo.type='special'\
and data.model = 'ir.actions.todo' and data.module=%s", (module.name, ))
if need_update:
cr.commit()
self.pool = pooler.restart_pool(cr.dbname, update_module=True)[1]
return self.pool.get('res.config').next(cr, uid, [], context=context)
#Migrate data from another application Conf wiz
class migrade_application_installer_modules(osv.osv_memory):

View File

@ -1,36 +1,6 @@
<openerp>
<data>
<record model="ir.actions.act_window" id="action_base_setup_installer_beta">
<field name="name">Install Applications</field>
<field name="res_model">base.setup.installer</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record id="base_setup_installer_todo" model="ir.actions.todo">
<field name="action_id" ref="action_base_setup_installer_beta" />
<field name="category_id" ref="base.category_administration_config"/>
<field name="sequence">2</field>
</record>
<record id="action_start_configurator" model="ir.actions.server">
<field name="name">Start Configuration</field>
<field name="model_id" ref="base.model_ir_actions_todo"/>
<field name="state">code</field>
<field name="code" eval="'# obj is a browse_record and will provide stupid ids to method\n' 'action = pool.get(\'ir.actions.todo\').action_launch(cr, uid, ' + str([ref('base_setup_installer_todo')]) + ', context=context)'"/>
</record>
<menuitem name="Add More Features" action="action_start_configurator" id="menu_view_base_module_configuration" parent="base.menu_config" type="server" icon="STOCK_EXECUTE" sequence="1"/>
<record id="ir_ui_view_sc_configuration" model="ir.ui.view_sc">
<field name="name">Add More Features</field>
<field name="resource">ir.ui.menu</field>
<field name="user_id" ref="base.user_root"/>
<field name="res_id" ref="menu_view_base_module_configuration" />
</record>
<!-- Import or create customers configartion view -->
<record id="action_import_create_installer" model="ir.actions.act_window">
<field name="name">Create or Import Customers</field>