- Configure Simple View
+ Select Your Interfaceir.actions.act_windowres.config.viewform
+ formnew
@@ -289,21 +308,11 @@
- Create User
- Create your users.
-You will be able to assign groups to users. Groups define the access rights of each users on the different objects of the system.
- 10
- Select Your Interface
- Choose between the "Simplified Interface" or the extended one.
-If you are testing or using OpenERP for the first time, we suggest you to use
-the simplified interface, which has less options and fields but is easier to
-understand. You will be able to switch to the extended view later.
- 5
diff --git a/bin/addons/base/ir/ir.xml b/bin/addons/base/ir/ir.xml
index a7b2aa81c37..8c49b789f9c 100644
--- a/bin/addons/base/ir/ir.xml
+++ b/bin/addons/base/ir/ir.xml
@@ -1342,11 +1342,10 @@
tree
-
-
+
-
+
@@ -1356,12 +1355,10 @@
form
-
-
-
+
-
+
@@ -1370,42 +1367,18 @@
ir.actions.todoform
- [('type','=','configure')]
-
- Main Configuration Wizard
- ir.actions.configuration.wizard
- form
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ Start Configuration
+
+ code
+ action = self.next(cr, uid, [])
-
-
- Configuration Wizard
- ir.actions.act_window
- ir.actions.configuration.wizard
- form
- form
- new
-
-
-
+
diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py
index 17a81d8e1f2..c850a363217 100644
--- a/bin/addons/base/ir/ir_actions.py
+++ b/bin/addons/base/ir/ir_actions.py
@@ -28,7 +28,6 @@ import netsvc
import re
import copy
import sys
-
from xml import dom
class actions(osv.osv):
@@ -344,59 +343,6 @@ class ir_model_fields(osv.osv):
_columns = {
'complete_name': fields.char('Complete Name', size=64, select=1),
}
-
- def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100):
- return super(ir_model_fields, self).name_search(cr, uid, name, args, operator, context, limit)
-# def get_fields(cr, uid, field, rel):
-# result = []
-# mobj = self.pool.get('ir.model')
-# id = mobj.search(cr, uid, [('model','=',rel)])
-
-# obj = self.pool.get('ir.model.fields')
-# ids = obj.search(cr, uid, [('model_id','in',id)])
-# records = obj.read(cr, uid, ids)
-# for record in records:
-# id = record['id']
-# fld = field + '/' + record['name']
-
-# result.append((id, fld))
-# return result
-
-# if not args:
-# args=[]
-# if not context:
-# context={}
-# return super(ir_model_fields, self).name_search(cr, uid, name, args, operator, context, limit)
-
-# if context.get('key') != 'server_action':
-# return super(ir_model_fields, self).name_search(cr, uid, name, args, operator, context, limit)
-# result = []
-# obj = self.pool.get('ir.model.fields')
-# ids = obj.search(cr, uid, args)
-# records = obj.read(cr, uid, ids)
-# for record in records:
-# id = record['id']
-# field = record['name']
-
-# if record['ttype'] == 'many2one':
-# rel = record['relation']
-# res = get_fields(cr, uid, field, record['relation'])
-# for rs in res:
-# result.append(rs)
-
-# result.append((id, field))
-
-# for rs in result:
-# obj.write(cr, uid, [rs[0]], {'complete_name':rs[1]})
-
-# iids = []
-# for rs in result:
-# iids.append(rs[0])
-
-# result = super(ir_model_fields, self).name_search(cr, uid, name, [('complete_name','ilike',name), ('id','in',iids)], operator, context, limit)
-
-# return result
-
ir_model_fields()
class server_object_lines(osv.osv):
@@ -429,7 +375,7 @@ class actions_server(osv.osv):
result = cr.fetchall() or []
res = []
for rs in result:
- if not rs[0] == None and not rs[1] == None:
+ if rs[0] is not None and rs[1] is not None:
res.append(rs)
return res
@@ -577,8 +523,8 @@ class actions_server(osv.osv):
if action.state=='client_action':
if not action.action_id:
raise osv.except_osv(_('Error'), _("Please specify an action to launch !"))
- result = self.pool.get(action.action_id.type).read(cr, uid, action.action_id.id, context=context)
- return result
+ return self.pool.get(action.action_id.type)\
+ .read(cr, uid, action.action_id.id, context=context)
if action.state == 'code':
localdict = {
@@ -733,128 +679,29 @@ class act_window_close(osv.osv):
act_window_close()
# This model use to register action services.
-# if action type is 'configure', it will be start on configuration wizard.
-# if action type is 'service',
-# - if start_type= 'at once', it will be start at one time on start date
-# - if start_type='auto', it will be start on auto starting from start date, and stop on stop date
-# - if start_type="manual", it will start and stop on manually
+TODO_STATES = [('open', 'Not Started'),
+ ('done', 'Done'),
+ ('skip','Skipped'),
+ ('cancel','Cancel')]
class ir_actions_todo(osv.osv):
_name = 'ir.actions.todo'
_columns={
- 'name':fields.char('Name',size=64,required=True, select=True),
- 'note':fields.text('Text', translate=True),
- 'start_date': fields.datetime('Start Date'),
- 'end_date': fields.datetime('End Date'),
- 'action_id':fields.many2one('ir.actions.act_window', 'Action', select=True,required=True, ondelete='cascade'),
- 'sequence':fields.integer('Sequence'),
+ 'action_id': fields.many2one(
+ 'ir.actions.act_window', 'Action', select=True, required=True,
+ ondelete='cascade'),
+ 'sequence': fields.integer('Sequence'),
'active': fields.boolean('Active'),
- 'type':fields.selection([('configure', 'Configure'),('service', 'Service'),('other','Other')], string='Type', required=True),
- 'start_on':fields.selection([('at_once', 'At Once'),('auto', 'Auto'),('manual','Manual')], string='Start On'),
- 'groups_id': fields.many2many('res.groups', 'res_groups_act_todo_rel', 'act_todo_id', 'group_id', 'Groups'),
- 'users_id': fields.many2many('res.users', 'res_users_act_todo_rel', 'act_todo_id', 'user_id', 'Users'),
- 'state':fields.selection([('open', 'Not Started'),('done', 'Done'),('skip','Skipped'),('cancel','Cancel')], string='State', required=True)
+ 'state': fields.selection(TODO_STATES, string='State', required=True),
+ 'name':fields.char('Name', size=64),
+ 'note':fields.text('Text', translate=True),
}
_defaults={
'state': lambda *a: 'open',
'sequence': lambda *a: 10,
- 'active':lambda *a:True,
- 'type':lambda *a:'configure'
+ 'active': lambda *a: True,
}
_order="sequence"
ir_actions_todo()
-# This model to use run all configuration actions
-class ir_actions_configuration_wizard(osv.osv_memory):
- _name='ir.actions.configuration.wizard'
- def next_configuration_action(self,cr,uid,context={}):
- item_obj = self.pool.get('ir.actions.todo')
- item_ids = item_obj.search(cr, uid, [('type','=','configure'),('state', '=', 'open'),('active','=',True)], limit=1, context=context)
- if item_ids and len(item_ids):
- item = item_obj.browse(cr, uid, item_ids[0], context=context)
- return item
- return False
- def _get_action_name(self, cr, uid, context={}):
- next_action=self.next_configuration_action(cr,uid,context=context)
- if next_action:
- return next_action.note
- else:
- return "Your database is now fully configured.\n\nClick 'Continue' and enjoy your OpenERP experience..."
- return False
-
- def _get_action(self, cr, uid, context={}):
- next_action=self.next_configuration_action(cr,uid,context=context)
- if next_action:
- return next_action.id
- return False
-
- def _progress_get(self,cr,uid, context={}):
- total = self.pool.get('ir.actions.todo').search_count(cr, uid, [], context)
- todo = self.pool.get('ir.actions.todo').search_count(cr, uid, [('type','=','configure'),('active','=',True),('state','<>','open')], context)
- if total > 0.0:
- return max(5.0,round(todo*100/total))
- else:
- return 100.0
-
- _columns = {
- 'name': fields.text('Next Wizard',readonly=True),
- 'progress': fields.float('Configuration Progress', readonly=True),
- 'item_id':fields.many2one('ir.actions.todo', 'Next Configuration Wizard',invisible=True, readonly=True),
- }
- _defaults={
- 'progress': _progress_get,
- 'item_id':_get_action,
- 'name':_get_action_name,
- }
- def button_next(self,cr,uid,ids,context=None):
- user_action=self.pool.get('res.users').browse(cr,uid,uid)
- act_obj=self.pool.get(user_action.menu_id.type)
- action_ids=act_obj.search(cr,uid,[('name','=',user_action.menu_id.name)])
- action_open=act_obj.browse(cr,uid,action_ids)[0]
- if context.get('menu',False):
- return{
- 'view_type': action_open.view_type,
- 'view_id':action_open.view_id and [action_open.view_id.id] or False,
- 'res_model': action_open.res_model,
- 'type': action_open.type,
- 'domain':action_open.domain
- }
- return {'type':'ir.actions.act_window_close'}
-
- def button_skip(self,cr,uid,ids,context=None):
- item_obj = self.pool.get('ir.actions.todo')
- 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',
- "view_mode": 'form',
- 'res_model': 'ir.actions.configuration.wizard',
- 'type': 'ir.actions.act_window',
- 'target':'new',
- }
- return self.button_next(cr, uid, ids, context)
-
- def button_continue(self, cr, uid, ids, context=None):
- item_obj = self.pool.get('ir.actions.todo')
- 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_mode': item.action_id.view_mode,
- '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 self.button_next(cr, uid, ids, context)
-ir_actions_configuration_wizard()
-
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/bin/addons/base/ir/ir_model.py b/bin/addons/base/ir/ir_model.py
index c5361fd952d..99444bd475d 100644
--- a/bin/addons/base/ir/ir_model.py
+++ b/bin/addons/base/ir/ir_model.py
@@ -610,38 +610,4 @@ class ir_model_data(osv.osv):
return True
ir_model_data()
-class ir_model_config(osv.osv):
- _name = 'ir.model.config'
- _columns = {
- 'password': fields.char('Password', size=64),
- 'password_check': fields.char('Confirmation', size=64),
- }
-
- def action_cancel(self, cr, uid, ids, context={}):
- return {
- 'view_type': 'form',
- "view_mode": 'form',
- 'res_model': 'ir.actions.configuration.wizard',
- 'type': 'ir.actions.act_window',
- 'target':'new',
- }
-
- def action_update_pw(self, cr, uid, ids, context={}):
- res = self.read(cr,uid,ids)[0]
- root = self.pool.get('res.users').browse(cr, uid, [1])[0]
- self.unlink(cr, uid, [res['id']])
- if res['password']!=res['password_check']:
- raise except_orm(_('Error'), _("Password mismatch !"))
- elif not res['password']:
- raise except_orm(_('Error'), _("Password empty !"))
- self.pool.get('res.users').write(cr, uid, [root.id], {'password':res['password']})
- return {
- 'view_type': 'form',
- "view_mode": 'form',
- 'res_model': 'ir.actions.configuration.wizard',
- 'type': 'ir.actions.act_window',
- 'target':'new',
- }
-ir_model_config()
-
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/bin/addons/base/module/wizard/wizard_module_upgrade.py b/bin/addons/base/module/wizard/wizard_module_upgrade.py
index 051d6ca00c4..40d100fe2e0 100644
--- a/bin/addons/base/module/wizard/wizard_module_upgrade.py
+++ b/bin/addons/base/module/wizard/wizard_module_upgrade.py
@@ -92,13 +92,8 @@ class wizard_info_get(wizard.interface):
return {}
def _config(self, cr, uid, data, context=None):
- return {
- 'view_type': 'form',
- "view_mode": 'form',
- 'res_model': 'ir.actions.configuration.wizard',
- 'type': 'ir.actions.act_window',
- 'target':'new',
- }
+ return pooler.get_pool(cr.dbname).get('res.config')\
+ .next(cr, uid, [], context=context)
states = {
'init': {
@@ -183,13 +178,8 @@ class wizard_info_get_simple(wizard.interface):
return {}
def _config(self, cr, uid, data, context=None):
- return {
- 'view_type': 'form',
- "view_mode": 'form',
- 'res_model': 'ir.actions.configuration.wizard',
- 'type': 'ir.actions.act_window',
- 'target':'new',
- }
+ return pooler.get_pool(cr.dbname).get('res.config')\
+ .next(cr, uid, [], context=context)
states = {
'init': {
diff --git a/bin/addons/base/res/__init__.py b/bin/addons/base/res/__init__.py
index d8b335f590f..66278c82087 100644
--- a/bin/addons/base/res/__init__.py
+++ b/bin/addons/base/res/__init__.py
@@ -25,6 +25,7 @@ import country
import bank
import res_lang
import partner
+import res_config
import res_currency
import res_company
import res_user
diff --git a/bin/addons/base/res/partner/partner.py b/bin/addons/base/res/partner/partner.py
index be5819ec79b..9d91e898b57 100644
--- a/bin/addons/base/res/partner/partner.py
+++ b/bin/addons/base/res/partner/partner.py
@@ -271,7 +271,15 @@ class res_partner(osv.osv):
if (not context.get('category_id', False)):
return False
return _('Partners: ')+self.pool.get('res.partner.category').browse(cr, uid, context['category_id'], context).name
-
+ def main_partner(self, cr, uid):
+ ''' Return the id of the main partner
+ '''
+ model_data = self.pool.get('ir.model.data')
+ return model_data.browse(
+ cr, uid,
+ model_data.search(cr, uid, [('module','=','base'),
+ ('name','=','main_partner')])[0],
+ ).res_id
res_partner()
class res_partner_address(osv.osv):
diff --git a/bin/addons/base/res/res_config.py b/bin/addons/base/res/res_config.py
new file mode 100644
index 00000000000..0060de4e1d1
--- /dev/null
+++ b/bin/addons/base/res/res_config.py
@@ -0,0 +1,149 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from osv import osv, fields
+import netsvc
+
+class res_config_configurable(osv.osv_memory):
+ ''' Base classes for new-style configuration items
+
+ Configuration items should inherit from this class, implement
+ the execute method (and optionally the cancel one) and have
+ their view inherit from the related res_config_view_base view.
+ '''
+ _name = 'res.config'
+ logger = netsvc.Logger()
+
+ def _progress(self, cr, uid, context=None):
+ total = self.pool.get('ir.actions.todo')\
+ .search_count(cr, uid, [], context)
+ open = self.pool.get('ir.actions.todo')\
+ .search_count(cr, uid, [('active','=',True),
+ ('state','<>','open')],
+ context)
+ if total:
+ return round(open*100./total)
+ return 100.
+
+ _columns = dict(
+ progress=fields.float('Configuration Progress', readonly=True),
+ )
+ _defaults = dict(
+ progress=_progress
+ )
+
+ def _next_action(self, cr, uid):
+ todos = self.pool.get('ir.actions.todo')
+ self.logger.notifyChannel('actions', netsvc.LOG_INFO,
+ 'getting next %s' % todos)
+ active_todos = todos.search(cr, uid, [('state','=','open'),
+ ('active','=',True)],
+ limit=1, context=None)
+ if active_todos:
+ return todos.browse(cr, uid, active_todos[0], context=None)
+ return None
+
+ def _next(self, cr, uid):
+ self.logger.notifyChannel('actions', netsvc.LOG_INFO,
+ 'getting next operation')
+ next = self._next_action(cr, uid)
+ self.logger.notifyChannel('actions', netsvc.LOG_INFO,
+ 'next action is %s' % next)
+ if next:
+ self.pool.get('ir.actions.todo').write(cr, uid, next.id, {
+ 'state':'done',
+ }, context=None)
+ action = next.action_id
+ return {
+ 'view_mode': action.view_mode,
+ 'view_type': action.view_type,
+ 'view_id': action.view_id and [action.view_id.id] or False,
+ 'res_model': action.res_model,
+ 'type': action.type,
+ 'target': action.target,
+ }
+ self.logger.notifyChannel(
+ 'actions', netsvc.LOG_INFO,
+ 'all configuration actions have been executed')
+
+ current_user_menu = self.pool.get('res.users')\
+ .browse(cr, uid, uid).menu_id
+ # return the action associated with the menu
+ return self.pool.get(current_user_menu.type)\
+ .read(cr, uid, current_user_menu.id)
+ def next(self, cr, uid, ids, context=None):
+ return self._next(cr, uid)
+
+ def execute(self, cr, uid, ids, context=None):
+ raise NotImplementedError(
+ 'Configuration items need to implement execute')
+ def cancel(self, cr, uid, ids, context=None):
+ pass
+
+ def action_next(self, cr, uid, ids, context=None):
+ next = self.execute(cr, uid, ids, context=None)
+ if next: return next
+ return self.next(cr, uid, ids, context=context)
+
+ def action_skip(self, cr, uid, ids, context=None):
+ next = self.cancel(cr, uid, ids, context=None)
+ if next: return next
+ return self.next(cr, uid, ids, context=context)
+res_config_configurable()
+
+DEPRECATION_MESSAGE = 'You are using an addon using old-style configuration '\
+ 'wizards (ir.actions.configuration.wizard). Old-style configuration '\
+ 'wizards have been deprecated.\n'\
+ 'The addon should be migrated to res.config objects.'
+class ir_actions_configuration_wizard(osv.osv_memory):
+ ''' Compatibility configuration wizard
+
+ The old configuration wizard has been replaced by res.config, but in order
+ not to break existing but not-yet-migrated addons, the old wizard was
+ reintegrated and gutted.
+ '''
+ _name='ir.actions.configuration.wizard'
+ _inherit = 'res.config'
+
+ def _next_action_note(self, cr, uid, ids, context=None):
+ next = self._next_action(cr, uid)
+ if next:
+ # if the next one is also an old-style extension, you never know...
+ if next.note:
+ return next.note
+ return "Click 'Continue' to configure the next addon..."
+ return "Your database is now fully configured.\n\n"\
+ "Click 'Continue' and enjoy your OpenERP experience..."
+
+ _columns = {
+ 'note': fields.text('Next Wizard', readonly=True),
+ }
+ _defaults = {
+ 'note': _next_action_note,
+ }
+
+ def execute(self, cr, uid, ids, context=None):
+ self.logger.notifyChannel(
+ 'configuration', netsvc.LOG_WARNING, DEPRECATION_MESSAGE)
+
+ir_actions_configuration_wizard()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/bin/addons/base/res/res_config.xml b/bin/addons/base/res/res_config.xml
new file mode 100644
index 00000000000..2b1d3b45d42
--- /dev/null
+++ b/bin/addons/base/res/res_config.xml
@@ -0,0 +1,51 @@
+
+
+
+ res.config.view.base
+ res.config
+ form
+
+