[IMP]: olap: Converted Load column and Query Logs wizrd into osv memory wizard

bzr revid: ksa@tinyerp.co.in-20100315060138-l0cygthavv1ht1vs
This commit is contained in:
ksa (Open ERP) 2010-03-15 11:31:38 +05:30
parent d4e351bbb4
commit 5479a4e88e
10 changed files with 197 additions and 326 deletions

View File

@ -10,8 +10,10 @@
""",
"init_xml" : ["data/olap_data.xml"],
"update_xml" : [
"data/olap_view.xml",
"wizard/olap_query_logs_clear_view.xml",
"wizard/olap_load_column_view.xml",
"data/olap_wizard.xml",
"data/olap_view.xml",
"data/olap_cube_view.xml",
"data/olap_fact_view.xml",
"data/olap_cube_workflow.xml",

View File

@ -81,7 +81,7 @@
<field name="active"/>
<field name="hide"/>
<!-- <button name="show_col_view" string="Columns" type="object"/>-->
<!--<button string="Columns_wiz" name="%(bi_load_column)d" type="action"/>-->
<button name="hide_col" string="Hide" type="object"/>
<button name="show_col" string="Show" type="object"/>
</tree>
@ -108,7 +108,7 @@
<button name="hide_col" string="Hide" type="object"/>
<button name="show_col" string="Show" type="object"/>
</tree>
</field>
</field>
<field name="fact_database_id" select="1" colspan="2"/>
<field name="active"/>
<field name="hide"/>
@ -150,7 +150,7 @@
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_olap_database_columns_tree_m20">
<field name="name">olap.database.columns.tree.m20</field>
<field name="model">olap.database.columns</field>
@ -165,7 +165,7 @@
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_olap_database_columns_form">
<field name="name">olap.database.columns.form</field>
<field name="model">olap.database.columns</field>
@ -318,7 +318,7 @@
<form string="Olap Application Field">
<newline/>
<field name="name" select="1" colspan="2"/>
<field name="field_name" select="1" />
<field name="field_name" select="1" />
<field name="table_name" select="1" />
<newline/>
<field name="is_hidden" select="1" colspan="2"/>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard
string="Query Builder"
model="olap.schema"
@ -9,8 +9,6 @@
menu= "False"
multi="True"
id="bi_conf_cube_query_builder"/>
<!-- <menuitem name="Query Builder" action="bi_conf_cube_query_builder" type="wizard" id="menu_bi_conf_cube_query_builder" sequence="40" parent="menu_bi_conf_tools"/>
-->
<wizard
string="Load Tables"
@ -28,20 +26,19 @@
menu= "False"
multi="True"
id="bi_menu_olap_load_table"/>
<wizard
string="Open Configuration"
model="olap.schema"
name="olap.load.configuration.table"
menu= "False"
multi="True"
id="bi_load_configuration_table"/>
id="bi_load_configuration_table"/>
<wizard
string="Configure from Application"
model="olap.schema"
name="olap.application.configuration"
menu="False"
multi="True"
id="bi_application_configuration"/>
@ -50,24 +47,10 @@
model="olap.fact.database"
name="olap.fact.database.test_connection"
menu="False"
id="bi_test_connection"/>
<wizard
string="Open Columns"
model="olap.database.columns"
name="olap.load.column"
menu= "False"
multi="True"
id="bi_load_column"/>
<wizard
string="Clear Logs"
model="olap.query.logs"
name="olap.query.logs.clear"
menu="True"
id="bi_clear_logs"/>
<menuitem name="Clear Logs" action="bi_clear_logs" type="wizard" id="menu_bi_clear_logs" sequence="30" parent="menu_bi_conf_tools"/>
id="bi_test_connection"/>
<menuitem name="Clear Logs" action="action_view_olap_query_logs_clear" icon="STOCK_EXECUTE"
id="menu_bi_clear_logs" sequence="30" parent="menu_bi_conf_tools"/>
</data>
</openerp>

View File

@ -28,7 +28,7 @@
import wizard_query_builder
import wizard_load_data
import wizard_load_configured_table
import wizard_clear_logs
import wizard_application_configure
import wizard_load_columns
import wizard_test_connection
#import wizard_application_configure
import olap_query_logs_clear
import olap_load_column

View File

@ -24,17 +24,25 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
from osv import fields, osv
from service import web_services
import pooler
import time
import wizard
class wizard_load_columns(wizard.interface):
def _get_table_data(self, cr, uid, data, context={}):
pool_obj = pooler.get_pool(cr.dbname)
ids_cols=pool_obj.get('olap.database.columns').search(cr, uid, ([('table_id','=',data['id'])]),context={})
model_data_ids = pool_obj.get('ir.model.data').search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_olap_database_columns_form')],context={})
resource_id = pool_obj.get('ir.model.data').read(cr,uid,model_data_ids,fields=['res_id'])[0]['res_id']
class olap_load_column(osv.osv_memory):
""" Load Database Column """
_name = "olap.load.column"
_description = "Olap Load Column"
def get_table_data(self, cr, uid, ids, context={}):
ids_cols=self.pool.get('olap.database.columns').search(cr, uid,\
([('table_id','=',context['active_id'])]),context={})
model_data_ids = self.pool.get('ir.model.data').search(cr,uid,\
[('model','=','ir.ui.view'),\
('name','=','view_olap_database_columns_form')],context={})
resource_id = self.pool.get('ir.model.data').read(cr,uid,\
model_data_ids,fields=['res_id'])[0]['res_id']
return {
'domain': "[('id','in', ["+','.join(map(str,ids_cols))+"])]",
'name': 'Database Columns',
@ -44,12 +52,10 @@ class wizard_load_columns(wizard.interface):
'views': [(False,'tree'),(resource_id,'form')],
'type': 'ir.actions.act_window',
}
states = {
'init' : {
'actions' : [],
'result' : {'type' : 'action' ,'action':_get_table_data,'state':'end'}
}
}
_columns = {
wizard_load_columns('olap.load.column')
}
olap_load_column()
# vim: ts=4 sts=4 sw=4 si et

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_olap_load_column" model="ir.ui.view">
<field name="name">Create Logs</field>
<field name="model">olap.load.column</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="">
<separator string=" " colspan="4"/>
<button name="get_table_data" string="Open" type="object"/>
</form>
</field>
</record>
<record id="action_olap_load_column" model="ir.actions.act_window">
<field name="name">Open Columns</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">olap.load.column</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="context">{'record_id' : active_id}</field>
<field name="target">new</field>
</record>
<record model="ir.values" id="lap_load_column">
<field name="model_id" ref="olap.model_olap_database_columns" />
<field name="object" eval="1" />
<field name="name">Open Columns</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_olap_load_column'))" />
<field name="key">action</field>
<field name="model">olap.database.columns</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,75 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from osv import fields, osv
from service import web_services
import pooler
import time
import wizard
class olap_query_logs_clear(osv.osv_memory):
""" Clear the Logs for Given User """
_name = "olap.query.logs.clear"
_description = "Olap Query Logs Clear"
_columns = {
'user_name':fields.char('User',size=64,required=True,readonly=True),
}
def _getdata(self,cr,uid,context={}):
user = self.pool.get('res.users').browse(cr,uid,uid)
return user.name
_defaults = {
'user_name': _getdata
}
def clear_logs(self,cr,uid,part,context={}):
ids = self.pool.get('olap.query.logs').search(cr,uid,[('user_id','=',uid)])
self.pool.get('olap.query.logs').unlink(cr, uid,ids,context)
data_obj = self.pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'olap', 'view_olap_query_logs_clear_msg')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
value = {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'olap.query.logs.clear.msg',
'views': [(id2,'form'),(False,'tree'),(False,'calendar'),(False,'graph')],
'type': 'ir.actions.act_window',
'target': 'new'
}
return value
olap_query_logs_clear()
class olap_query_logs_clear_msg(osv.osv_memory):
_name = "olap.query.logs.clear.msg"
_description = "Olap Query Logs Clear Message"
_columns = {
}
olap_query_logs_clear_msg()
# vim: ts=4 sts=4 sw=4 si et

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_olap_query_logs_clear" model="ir.ui.view">
<field name="name">Create Logs</field>
<field name="model">olap.query.logs.clear</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string=" To Load Data">
<field name='user_name'/>
<separator string="" colspan="4" />
<label string="" colspan="2" />
<group colspan="4">
<button special="cancel" string="Cancel" />
<button name="clear_logs" string="Clear Logs" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_view_olap_query_logs_clear" model="ir.actions.act_window">
<field name="name">Create Logs </field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">olap.query.logs.clear</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record id="view_olap_query_logs_clear_msg" model="ir.ui.view">
<field name="name">Create Logs Message</field>
<field name="model">olap.query.logs.clear.msg</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Load Data">
<label string="Logs Cleared successfully"/>
<group colspan="4">
<button special="cancel" string="Ok" />
</group>
</form>
</field>
</record>
</data>
</openerp>

View File

@ -1,194 +0,0 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
import pooler
from osv import osv
import netsvc
info = '''<?xml version="1.0"?>
<form string="Auto Configure">
<label string="Your database structure (Open ERP) has been sucessfully configured."/>
</form>'''
form1 = '''<?xml version="1.0"?>
<form string=" Auto Configure ">
<label string="This will Auto Configure Application"/>
</form>'''
class wizard_application_configure(wizard.interface):
def configure_application(self,cr,uid,data,context):
vals={}
apptabnew_vals={}
appfieldnew_vals={}
ids=pooler.get_pool(cr.dbname).get('olap.schema').browse(cr,uid,data['id'])
if ids.app_detect == "Unknown Application":
raise wizard.except_wizard('Warning', 'The Application is Unknown, we can not configure it automatically.')
else:
app_objs = pooler.get_pool(cr.dbname).get('olap.application')
app_ids = app_objs.search(cr, uid, [])
app_res = app_objs.browse(cr,uid, app_ids)
app_id=''
for x_app in app_res:
app_id = x_app['id']
apptab_objs = pooler.get_pool(cr.dbname).get('olap.application.table')
apptab_ids = apptab_objs.search(cr, uid, [])
apptab_res = apptab_objs.browse(cr,uid, apptab_ids)
apptab_name=[]
for aptab in apptab_res:
apptab_name.append(aptab.name)
appfield_objs = pooler.get_pool(cr.dbname).get('olap.application.field')
appfield_ids = appfield_objs.search(cr, uid, [])
appfield_res = appfield_objs.browse(cr,uid, appfield_ids)
appcol_name=[]
for apcol in appfield_res:
appcol_name.append(apcol.name)
apptab_objs = pooler.get_pool(cr.dbname).get('olap.application.table')
apptab_ids = apptab_objs.search(cr, uid, [])
apptab_res = apptab_objs.browse(cr,uid, apptab_ids)
# apptab_data_res = apptab_objs.read(cr,uid, apptab_ids,[])[0]
apptab_name=[]
map_apptab_name_id={}
for aptab in apptab_res:
apptab_name.append(aptab.name)
map_apptab_name_id[aptab.table_name]=aptab
appfield_objs = pooler.get_pool(cr.dbname).get('olap.application.field')
appfield_ids = appfield_objs.search(cr, uid, [])
appfield_res = appfield_objs.browse(cr,uid, appfield_ids)
appfield_data_res = appfield_objs.read(cr,uid, appfield_ids,[])
appcol_name=[]
for apcol in appfield_res:
appcol_name.append(apcol.name)
id_tables=pooler.get_pool(cr.dbname).get('olap.database.tables').search(cr,uid,[('fact_database_id','=',ids.database_id.id),('table_db_name','not in',['inherit','res_roles','user_rule_group_rel','res_roles_users_rel','group_rule_group_rel'])])
tables=pooler.get_pool(cr.dbname).get('olap.database.tables').read(cr,uid,id_tables,[])
for tables in tables:
if not(tables['table_db_name'].startswith('ir') or tables['table_db_name'].startswith('wkf') or tables['table_db_name'].startswith('res_groups')):
vals={}
if len(apptab_ids)==0 and (tables['table_db_name'] not in apptab_name):
vals['table_name']=tables['table_db_name']
vals['name']=(" ").join(map(lambda x:x.capitalize(),tables['name'].split("_")))
vals['is_hidden']=tables['hide']
vals['application_id']=app_id
apptab_new_obj=apptab_objs.create(cr,uid,vals)
else:
if map_apptab_name_id.has_key(tables['table_db_name']):
app_table = map_apptab_name_id[tables['table_db_name']]
if ((app_table['table_name']==tables['table_db_name']) and not (app_table['table_name']==tables['name'])):
vals['name']=aptable_obj.table_name
vals['hide']=aptable_obj.is_hidden
tables_obj_new=apptab_objs.write(cr,uid,tables['id'],vals)
else:
vals['table_name']=tables['table_db_name']
vals['name']=(" ").join(map(lambda x:x.capitalize(),tables['name'].split("_")))
vals['is_hidden']=tables['hide']
vals['application_id']=app_id
apptab_new_obj=apptab_objs.create(cr,uid,vals)
id_columns=pooler.get_pool(cr.dbname).get('olap.database.columns').search(cr,uid,[('table_id','in',id_tables)])
columns=pooler.get_pool(cr.dbname).get('olap.database.columns').read(cr,uid,id_columns,[])
for columns in columns:
vals={}
if len(appfield_ids) == 0 and (columns['column_db_name'] not in appcol_name):
vals['field_name']=columns['column_db_name']
vals['table_name']=columns['table_id'][1]
vals['name']=(" ").join(map(lambda x:x.capitalize(),columns['name'].split("_")))
vals['is_hidden']=columns['hide']
vals['application_id']=x_app['id']
appfield_new_obj=appfield_objs.create(cr,uid,vals)
else:
if map_apptab_name_id.has_key(columns['table_id'][1]):
table_id_write = map_apptab_name_id[columns['table_id'][1]]
filter_column=filter(lambda x: columns['column_db_name']==x['field_name'] and columns['table_id'][1]==x['table_name'],appfield_data_res)
vals['name']=(" ").join(map(lambda x:x.capitalize(),columns['name'].split("_")))
vals['is_hidden']=columns['hide']
appfield_new_obj=appfield_objs.write(cr,uid,filter_column[0]['id'],vals)
else:
vals['field_name']=columns['column_db_name']
vals['table_name']=columns['table_id'][1]
vals['name']=(" ").join(map(lambda x:x.capitalize(),columns['name'].split("_")))
vals['is_hidden']=columns['hide']
vals['application_id']=x_app['id']
appfield_new_obj=appfield_objs.create(cr,uid,vals)
database_tables = pooler.get_pool(cr.dbname).get('olap.database.tables')
id_tables=database_tables.search(cr,uid,[('fact_database_id','=',ids.database_id.id)])
tables=database_tables.read(cr,uid,id_tables,[])
make_id=[]
for table in tables:
vals={}
if (table['table_db_name'].startswith('ir') or table['table_db_name'].startswith('wkf')) or (table['table_db_name'].startswith('res_groups')) or (table['table_db_name'] in ['inherit','res_roles','user_rule_group_rel','res_roles_users_rel','group_rule_group_rel']):
vals['hide']=True
vals['active']=False
make_id.append(table['id'])
database_tables.write(cr,uid,table['id'],vals)
database_columns=pooler.get_pool(cr.dbname).get('olap.database.columns')
id_columns=database_columns.search(cr,uid,[('table_id','in',make_id)])
columns=database_columns.read(cr,uid,id_columns,[])
for col in columns:
val={}
vals['hide']=True
vals['active']=False
database_columns.write(cr,uid,col['id'],vals)
wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid, 'olap.schema', data['id'], 'dbconfigure', cr)
return {}
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':form1, 'fields':{}, 'state':[('configure','Configure'),('end','Cancel')]}
},
'configure': {
'actions': [configure_application],
'result': {'type':'form', 'arch':info, 'fields':{}, 'state':[('end','Ok')]}
},
}
wizard_application_configure('olap.application.configuration')
# vim: ts=4 sts=4 sw=4 si et

View File

@ -1,83 +0,0 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
import pooler
from osv import osv
info = '''<?xml version="1.0"?>
<form string="Load Data">
<label string="Logs Cleared successfully"/>
</form>'''
form1 = '''<?xml version="1.0"?>
<form string=" To Load Data">
<field name='user_name'/>
</form>'''
field1 = {
# 'account_id': {'string':"Analytic Account", 'type':'many2one', 'relation':'account.analytic.account', 'required':True, 'domain':"[('type','=','normal')]"},
'user_name': {'string':'User', 'type':'char','size':'64', 'required':True, 'readonly':True},
# 'db_name': {'string':'Database Name', 'type':'char','size':'64', 'required':True, 'readonly':True},
}
def clear_logs(self,cr,uid,part,context={}):
ids=pooler.get_pool(cr.dbname).get('olap.query.logs').search(cr,uid,[('user_id','=',uid)])
pooler.get_pool(cr.dbname).get('olap.query.logs').unlink(cr, uid,ids,context)
return {}
def _getdata(self,cr,uid,part,context={}):
ids=pooler.get_pool(cr.dbname).get('res.users').browse(cr,uid,uid)
part['form']['user_name']=ids['name']
# part['form']['db_name']=lines.database_id.db_name
return part['form']
class wizard_clear_logs(wizard.interface):
states = {
'init': {
'actions': [_getdata],
'result': {'type':'form','arch':form1, 'fields':field1, 'state':[('end','Cancel'),('ok','Clear Logs')]}
},
'ok': {
'actions': [clear_logs],
'result': {'type':'form','arch':info,'fields':{}, 'state':[('end','Ok')]}
},
'info': {
'actions': [],
'result': {'type':'form', 'arch':info, 'fields':{}, 'state':[('end','Ok')]}
},
}
wizard_clear_logs('olap.query.logs.clear')