[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
This commit is contained in:
parent
08f7728ff8
commit
97013e9aae
|
@ -1413,7 +1413,7 @@
|
|||
|
||||
<record id="action_start_configurator" model="ir.actions.server">
|
||||
<field name="name">Start Configuration</field>
|
||||
<field name="model_id" ref="model_ir_actions_configurator"/>
|
||||
<field name="model_id" ref="model_res_configurable"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">action = self.next(cr, uid)</field>
|
||||
</record>
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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:
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue