From 6c8eef526f0fd8e21beabbd3fd1919e3dcd7c7ba Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 2 Dec 2009 12:21:22 +0100 Subject: [PATCH 01/48] [fix] remove import of xml.xpath, death to pyxml bzr revid: xmo@tinyerp.com-20091202112122-taugkps2909a62b3 --- bin/addons/base/ir/ir_actions.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index 5f95f3bebdb..b11ec3418cd 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -28,13 +28,7 @@ import netsvc import re import copy import sys - -try: - from xml import dom, xpath -except ImportError: - sys.stderr.write("ERROR: Import xpath module\n") - sys.stderr.write("ERROR: Try to install the old python-xml package\n") - sys.exit(2) +from xml import dom class actions(osv.osv): _name = 'ir.actions.actions' From b608b4568295e0b184359360e6f261d007a191fa Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 2 Dec 2009 19:20:21 +0100 Subject: [PATCH 02/48] [IMP] Style fixes, 80c clamping bzr revid: xmo@tinyerp.com-20091202182021-uzj8zkxjiiuwo0d5 --- bin/addons/base/ir/ir_actions.py | 74 ++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index b11ec3418cd..438ce6a8442 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -428,7 +428,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 @@ -576,8 +576,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 = { @@ -767,67 +767,77 @@ 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 + item_ids = item_obj.search(cr, uid, + [('type','=','configure'), + ('state', '=', 'open'), + ('active','=',True)], + limit=1, context=context) + if item_ids: + return item_obj.browse(cr, uid, item_ids[0], context=context) return False def _get_action_name(self, cr, uid, context={}): - next_action=self.next_configuration_action(cr,uid,context=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) + next_action = self.next_configuration_action(cr, uid, context=context) if next_action: return next_action.id - return False + return - 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) + def _progress_get(self, cr, uid, context=None): + 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)) + return max(5.0, round(todo*100/total)) else: return 100.0 _columns = { - 'name': fields.text('Next Wizard',readonly=True), + '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), + '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, + '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{ + 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 and 'menu' in context: + return { 'view_type': action_open.view_type, - 'view_id':action_open.view_id and [action_open.view_id.id] or False, + '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 + 'domain': action_open.domain } - return {'type':'ir.actions.act_window_close'} + 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'] + 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{ + return { 'view_type': 'form', "view_mode": 'form', 'res_model': 'ir.actions.configuration.wizard', @@ -838,13 +848,13 @@ class ir_actions_configuration_wizard(osv.osv_memory): 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'] + 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{ + 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, From e593be387f3a3c3cc9cce5e09d821f05239051b6 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 2 Dec 2009 19:24:51 +0100 Subject: [PATCH 03/48] [rem] actually remove name_search which was partially removed in mga@tinyerp.com-20090916102521-m5xmlbmle8y2zc64 instead of leaving it commented bzr revid: xmo@tinyerp.com-20091202182451-ai0ra2m1uxrnx1kq --- bin/addons/base/ir/ir_actions.py | 53 -------------------------------- 1 file changed, 53 deletions(-) diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index 438ce6a8442..dcdbf319cfc 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -343,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=80): - 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): From 40050f1230474cca066c71f1f3cfaaa30dcd51c5 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 3 Dec 2009 13:31:10 +0100 Subject: [PATCH 04/48] [IMP] add new handler for addons configuration, corresponding menu item bzr revid: xmo@tinyerp.com-20091203123110-r1v2vycpe92bvvxc --- bin/addons/base/ir/ir.xml | 7 ++++++ bin/addons/base/ir/ir_actions.py | 37 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/bin/addons/base/ir/ir.xml b/bin/addons/base/ir/ir.xml index ea4273950a0..60d63b3464a 100644 --- a/bin/addons/base/ir/ir.xml +++ b/bin/addons/base/ir/ir.xml @@ -1411,5 +1411,12 @@ + + Start Configuration + + code + action = self.next(cr, uid) + + diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index dcdbf319cfc..f8c6dfa8810 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -812,5 +812,42 @@ class ir_actions_configuration_wizard(osv.osv_memory): return self.button_next(cr, uid, ids, context) ir_actions_configuration_wizard() +class ir_actions_configurator(osv.osv_memory): + _name = 'ir.actions.configurator' + logger = netsvc.Logger() + def next_action(self, cr, uid, context=None): + todos = self.pool.get('ir.actions.todo') + self.logger.notifyChannel('actions', netsvc.LOG_INFO, + 'getting next %s' % todos) + active_todos = todos.search(cr, uid, + [('type','=','configure'), + ('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, + } + return {'type': 'ir.actions.act_window_close'} +ir_actions_configurator() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 08f7728ff8f9f6ca293072a0c7f6af66bb7cf6fb Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 3 Dec 2009 14:09:04 +0100 Subject: [PATCH 05/48] [IMP] migrate res.user and res.config.view to the new configurator bzr revid: xmo@tinyerp.com-20091203130904-9ndprgw23f4jc0ne --- bin/addons/base/ir/ir_actions.py | 3 +++ bin/addons/base/res/res_user.py | 34 +++++--------------------------- 2 files changed, 8 insertions(+), 29 deletions(-) diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index f8c6dfa8810..5662422b4b3 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -847,6 +847,9 @@ class ir_actions_configurator(osv.osv_memory): 'type': action.type, 'target': action.target, } + self.logger.notifyChannel( + 'actions', netsvc.LOG_INFO, + 'all configuration actions have been executed') return {'type': 'ir.actions.act_window_close'} ir_actions_configurator() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/bin/addons/base/res/res_user.py b/bin/addons/base/res/res_user.py index d6b7cd6eec0..7fc985a70e5 100644 --- a/bin/addons/base/res/res_user.py +++ b/bin/addons/base/res/res_user.py @@ -255,22 +255,11 @@ class users(osv.osv): return dataobj.browse(cr, uid, data_id, context).res_id def action_next(self,cr,uid,ids,context=None): - return { - 'view_type': 'form', - "view_mode": 'form', - 'res_model': 'ir.actions.configuration.wizard', - 'type': 'ir.actions.act_window', - 'target':'new', - } + return self.pool.get('ir.actions.configurator').next(cr, uid) def action_continue(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', - } + return self.pool.get('ir.actions.configurator').next(cr, uid) + def action_new(self,cr,uid,ids,context={}): return { 'view_type': 'form', @@ -301,13 +290,7 @@ class res_config_view(osv.osv_memory): } def action_cancel(self,cr,uid,ids,conect=None): - return { - 'view_type': 'form', - "view_mode": 'form', - 'res_model': 'ir.actions.configuration.wizard', - 'type': 'ir.actions.act_window', - 'target':'new', - } + return self.pool.get('ir.actions.configurator').next(cr, uid) def action_set(self, cr, uid, ids, context=None): res=self.read(cr,uid,ids)[0] users_obj = self.pool.get('res.users') @@ -318,14 +301,7 @@ class res_config_view(osv.osv_memory): users_obj.write(cr, uid, [uid],{ 'groups_id':[(4,group_ids[0])] }, context=context) - return { - 'view_type': 'form', - "view_mode": 'form', - 'res_model': 'ir.actions.configuration.wizard', - 'type': 'ir.actions.act_window', - 'target':'new', - } - + return self.pool.get('ir.actions.configurator').next(cr, uid) res_config_view() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 97013e9aae34261d1be840568d7d271eb34321d2 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 3 Dec 2009 16:11:22 +0100 Subject: [PATCH 06/48] [IMP] modify configurator for inheritability, move it to res_config, make res_config_view inherit from res.configurable bzr revid: xmo@tinyerp.com-20091203151122-md545zxjs7rlyddk --- bin/addons/base/ir/ir.xml | 2 +- bin/addons/base/ir/ir_actions.py | 40 ------------------ bin/addons/base/res/__init__.py | 1 + bin/addons/base/res/res_config.py | 69 +++++++++++++++++++++++++++++++ bin/addons/base/res/res_user.py | 10 ++--- 5 files changed, 76 insertions(+), 46 deletions(-) create mode 100644 bin/addons/base/res/res_config.py diff --git a/bin/addons/base/ir/ir.xml b/bin/addons/base/ir/ir.xml index 60d63b3464a..9d538a8a155 100644 --- a/bin/addons/base/ir/ir.xml +++ b/bin/addons/base/ir/ir.xml @@ -1413,7 +1413,7 @@ Start Configuration - + code action = self.next(cr, uid) diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index 5662422b4b3..dcdbf319cfc 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -812,45 +812,5 @@ class ir_actions_configuration_wizard(osv.osv_memory): return self.button_next(cr, uid, ids, context) ir_actions_configuration_wizard() -class ir_actions_configurator(osv.osv_memory): - _name = 'ir.actions.configurator' - logger = netsvc.Logger() - def next_action(self, cr, uid, context=None): - todos = self.pool.get('ir.actions.todo') - self.logger.notifyChannel('actions', netsvc.LOG_INFO, - 'getting next %s' % todos) - active_todos = todos.search(cr, uid, - [('type','=','configure'), - ('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') - return {'type': 'ir.actions.act_window_close'} -ir_actions_configurator() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: 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/res_config.py b/bin/addons/base/res/res_config.py new file mode 100644 index 00000000000..39c10ea72c4 --- /dev/null +++ b/bin/addons/base/res/res_config.py @@ -0,0 +1,69 @@ +# -*- 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 +import netsvc + +class res_config_configurable(osv.osv_memory): + _name = 'res.configurable' + logger = netsvc.Logger() + + 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, + [('type','=','configure'), + ('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') + return {'type': 'ir.actions.act_window_close'} + def next(self, cr, uid, *args, **kwargs): + return self._next(cr, uid) +res_config_configurable() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/bin/addons/base/res/res_user.py b/bin/addons/base/res/res_user.py index 7fc985a70e5..943d6931c38 100644 --- a/bin/addons/base/res/res_user.py +++ b/bin/addons/base/res/res_user.py @@ -120,7 +120,6 @@ def _companies_get(self,cr, uid, context={}): class users(osv.osv): __admin_ids = {} _name = "res.users" - #_log_access = False def get_current_company(self, cr, uid): res=[] @@ -255,10 +254,10 @@ class users(osv.osv): return dataobj.browse(cr, uid, data_id, context).res_id def action_next(self,cr,uid,ids,context=None): - return self.pool.get('ir.actions.configurator').next(cr, uid) + return self.pool.get('res.configurable').next(cr, uid) def action_continue(self,cr,uid,ids,context={}): - return self.pool.get('ir.actions.configurator').next(cr, uid) + return self.pool.get('res.configurable').next(cr, uid) def action_new(self,cr,uid,ids,context={}): return { @@ -281,6 +280,7 @@ groups2() class res_config_view(osv.osv_memory): _name='res.config.view' + _inherit='res.configurable' _columns = { 'name':fields.char('Name', size=64), 'view': fields.selection([('simple','Simplified Interface'),('extended','Extended Interface')], 'View Mode', required=True ), @@ -290,7 +290,7 @@ class res_config_view(osv.osv_memory): } def action_cancel(self,cr,uid,ids,conect=None): - return self.pool.get('ir.actions.configurator').next(cr, uid) + return self.next(cr, uid) def action_set(self, cr, uid, ids, context=None): res=self.read(cr,uid,ids)[0] users_obj = self.pool.get('res.users') @@ -301,7 +301,7 @@ class res_config_view(osv.osv_memory): users_obj.write(cr, uid, [uid],{ 'groups_id':[(4,group_ids[0])] }, context=context) - return self.pool.get('ir.actions.configurator').next(cr, uid) + return self.next(cr, uid) res_config_view() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 02e431c411c4518f62e36e902142ef62dd309545 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 4 Dec 2009 11:15:43 +0100 Subject: [PATCH 07/48] [IMP] make users configurable via res.configurable Create a new user configuration object (res.config.users) whose job is to create new users instance and interact with the related views bzr revid: xmo@tinyerp.com-20091204101543-qpqfhaqvrpqfpcyi --- bin/addons/base/base_update.xml | 6 ++-- bin/addons/base/res/res_user.py | 64 ++++++++++++++++++++------------- 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/bin/addons/base/base_update.xml b/bin/addons/base/base_update.xml index 8af8d8667b2..e6bdd16f758 100644 --- a/bin/addons/base/base_update.xml +++ b/bin/addons/base/base_update.xml @@ -198,8 +198,8 @@ - res.users.confirm.form - res.users + res.config.users.confirm.form + res.config.users form
@@ -239,7 +239,7 @@ Configure User ir.actions.act_window - res.users + res.config.users form form diff --git a/bin/addons/base/res/res_user.py b/bin/addons/base/res/res_user.py index 943d6931c38..298b7282a7e 100644 --- a/bin/addons/base/res/res_user.py +++ b/bin/addons/base/res/res_user.py @@ -247,29 +247,46 @@ class users(osv.osv): if k.startswith('context_'): result[k[8:]] = getattr(user,k) return result - - def action_get(self, cr, uid, context={}): - dataobj = self.pool.get('ir.model.data') - data_id = dataobj._get_id(cr, 1, 'base', 'action_res_users_my') - return dataobj.browse(cr, uid, data_id, context).res_id - - def action_next(self,cr,uid,ids,context=None): - return self.pool.get('res.configurable').next(cr, uid) - - def action_continue(self,cr,uid,ids,context={}): - return self.pool.get('res.configurable').next(cr, uid) - - def action_new(self,cr,uid,ids,context={}): - return { - 'view_type': 'form', - "view_mode": 'form', - 'res_model': 'res.users', - 'view_id':self.pool.get('ir.ui.view').search(cr,uid,[('name','=','res.users.confirm.form')]), - 'type': 'ir.actions.act_window', - 'target':'new', - } users() +class config_users(osv.osv_memory): + _name = 'res.config.users' + _table = 'res_users' + _inherit = 'res.configurable' + + _columns = users._columns + _defaults = users._defaults + + def user_data(self, cr, uid, context=None): + ''' Gets the purely user part of the current config_user + instance, without the fields inherited from res.configurable + ''' + return self.read(cr, uid, uid, + users._columns.keys(), + context=context) + def create_user(self, cr, uid, context=None): + ''' create a new res.user instance from the data stored + in the current res.config.users + ''' + self.pool.get('res.users').create( + cr, uid, self.user_data(cr, uid, context), context) + + def action_next(self, cr, uid, ids, context=None): + return self.next(cr, uid) + + def action_new(self, cr, uid, ids, context=None): + self.create_user(cr, uid, context=context) + return { + 'view_type': 'form', + "view_mode": 'form', + 'res_model': 'res.config.users', + 'view_id':self.pool.get('ir.ui.view')\ + .search(cr,uid,[('name','=','res.config.users.confirm.form')]), + 'type': 'ir.actions.act_window', + 'target':'new', + } +config_users() + class groups2(osv.osv): ##FIXME: Is there a reason to inherit this object ? _inherit = 'res.groups' _columns = { @@ -277,10 +294,9 @@ class groups2(osv.osv): ##FIXME: Is there a reason to inherit this object ? } groups2() - class res_config_view(osv.osv_memory): - _name='res.config.view' - _inherit='res.configurable' + _name = 'res.config.view' + _inherit = 'res.configurable' _columns = { 'name':fields.char('Name', size=64), 'view': fields.selection([('simple','Simplified Interface'),('extended','Extended Interface')], 'View Mode', required=True ), From 0e4962391ef8cf253bca5e4e8e1004ac4b3a6878 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 4 Dec 2009 11:58:21 +0100 Subject: [PATCH 08/48] [IMP] rename res.configurable to res.config: inheriting from it makes an object a config item bzr revid: xmo@tinyerp.com-20091204105821-7133uv5p1b7n4euz --- bin/addons/base/ir/ir.xml | 2 +- bin/addons/base/res/res_config.py | 2 +- bin/addons/base/res/res_user.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/addons/base/ir/ir.xml b/bin/addons/base/ir/ir.xml index 9d538a8a155..f36f51c0a93 100644 --- a/bin/addons/base/ir/ir.xml +++ b/bin/addons/base/ir/ir.xml @@ -1413,7 +1413,7 @@ Start Configuration - + code action = self.next(cr, uid) diff --git a/bin/addons/base/res/res_config.py b/bin/addons/base/res/res_config.py index 39c10ea72c4..45abb8eef7e 100644 --- a/bin/addons/base/res/res_config.py +++ b/bin/addons/base/res/res_config.py @@ -23,7 +23,7 @@ from osv import osv import netsvc class res_config_configurable(osv.osv_memory): - _name = 'res.configurable' + _name = 'res.config' logger = netsvc.Logger() def _next_action(self, cr, uid): diff --git a/bin/addons/base/res/res_user.py b/bin/addons/base/res/res_user.py index 298b7282a7e..e0396a6d975 100644 --- a/bin/addons/base/res/res_user.py +++ b/bin/addons/base/res/res_user.py @@ -252,14 +252,14 @@ users() class config_users(osv.osv_memory): _name = 'res.config.users' _table = 'res_users' - _inherit = 'res.configurable' + _inherit = 'res.config' _columns = users._columns _defaults = users._defaults def user_data(self, cr, uid, context=None): ''' Gets the purely user part of the current config_user - instance, without the fields inherited from res.configurable + instance, without the fields inherited from res.config ''' return self.read(cr, uid, uid, users._columns.keys(), @@ -296,7 +296,7 @@ groups2() class res_config_view(osv.osv_memory): _name = 'res.config.view' - _inherit = 'res.configurable' + _inherit = 'res.config' _columns = { 'name':fields.char('Name', size=64), 'view': fields.selection([('simple','Simplified Interface'),('extended','Extended Interface')], 'View Mode', required=True ), From de37555dd9b71f5e1a958bc57e6dbb8533e9cd14 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 4 Dec 2009 13:14:52 +0100 Subject: [PATCH 09/48] [ADD] integrate progress bars into configuration dialogs bzr revid: xmo@tinyerp.com-20091204121452-3eibzrgingec5xd9 --- bin/addons/base/base_update.xml | 14 ++++++++++---- bin/addons/base/res/res_config.py | 21 ++++++++++++++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/bin/addons/base/base_update.xml b/bin/addons/base/base_update.xml index e6bdd16f758..cac68d65048 100644 --- a/bin/addons/base/base_update.xml +++ b/bin/addons/base/base_update.xml @@ -227,8 +227,11 @@ -