2010-01-06 13:34:05 +00:00
# -*- 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 fields , osv
2011-03-30 09:57:56 +00:00
import pooler
2011-04-12 09:09:20 +00:00
import pytz
2010-01-06 13:34:05 +00:00
class base_setup_installer ( osv . osv_memory ) :
_name = ' base.setup.installer '
_inherit = ' res.config.installer '
_install_if = {
( ' sale ' , ' crm ' ) : [ ' sale_crm ' ] ,
( ' sale ' , ' project ' ) : [ ' project_mrp ' ] ,
2010-10-09 16:01:43 +00:00
}
2010-01-06 13:34:05 +00:00
_columns = {
# Generic modules
2010-01-24 17:34:04 +00:00
' crm ' : fields . boolean ( ' Customer Relationship Management ' ,
help = " Helps you track and manage relations with customers such as "
" leads, requests or issues. Can automatically send "
" reminders, escalate requests or trigger business-specific "
" actions based on standard events. " ) ,
' sale ' : fields . boolean ( ' Sales Management ' ,
help = " Helps you handle your quotations, sale orders and invoicing "
" . " ) ,
' project ' : fields . boolean ( ' Project Management ' ,
help = " Helps you manage your projects and tasks by tracking them, "
2010-01-24 18:05:52 +00:00
" generating plannings, etc... " ) ,
2010-01-24 17:34:04 +00:00
' knowledge ' : fields . boolean ( ' Knowledge Management ' ,
help = " Lets you install addons geared towards sharing knowledge "
" with and between your employees. " ) ,
' stock ' : fields . boolean ( ' Warehouse Management ' ,
2010-10-10 17:32:39 +00:00
help = " Helps you manage your inventory and main stock operations: delivery orders, receptions, etc. " ) ,
2010-01-24 18:05:52 +00:00
' mrp ' : fields . boolean ( ' Manufacturing ' ,
help = " Helps you manage your manufacturing processes and generate "
" reports on those processes. " ) ,
2010-10-09 16:01:43 +00:00
' account_voucher ' : fields . boolean ( ' Invoicing ' ,
help = " Allows you to create your invoices and track the payments. It is an easier version of the accounting module for managers who are not accountants. " ) ,
' account_accountant ' : fields . boolean ( ' Accounting & Finance ' ,
help = " Helps you handle your accounting needs, if you are not an accountant, we suggest you to install only the Invoicing " ) ,
2010-01-24 18:05:52 +00:00
' purchase ' : fields . boolean ( ' Purchase Management ' ,
help = " Helps you manage your purchase-related processes such as "
" requests for quotations, supplier invoices, etc... " ) ,
' hr ' : fields . boolean ( ' Human Resources ' ,
2010-09-21 06:59:49 +00:00
help = " Helps you manage your human resources by encoding your employees structure, generating work sheets, tracking attendance and more. " ) ,
2010-01-24 18:05:52 +00:00
' point_of_sale ' : fields . boolean ( ' Point of Sales ' ,
help = " Helps you get the most out of your points of sales with "
" fast sale encoding, simplified payment mode encoding, "
" automatic picking lists generation and more. " ) ,
' marketing ' : fields . boolean ( ' Marketing ' ,
help = " Helps you manage your marketing campaigns step by step. " ) ,
2010-09-14 13:59:12 +00:00
' profile_tools ' : fields . boolean ( ' Extra Tools ' ,
2010-09-01 12:26:56 +00:00
help = " Lets you install various interesting but non-essential tools "
" like Survey, Lunch and Ideas box. " ) ,
2010-01-24 18:05:52 +00:00
' report_designer ' : fields . boolean ( ' Advanced Reporting ' ,
help = " Lets you install various tools to simplify and enhance "
" OpenERP ' s report creation. " ) ,
2010-01-06 13:34:05 +00:00
# Vertical modules
2010-06-14 10:28:26 +00:00
' product_expiry ' : fields . boolean ( ' Food Industry ' ,
2010-09-01 12:26:56 +00:00
help = " Installs a preselected set of OpenERP applications "
2010-09-21 06:59:49 +00:00
" which will help you manage your industry. " ) ,
2010-07-01 10:56:50 +00:00
' association ' : fields . boolean ( ' Associations ' ,
2010-01-24 18:05:52 +00:00
help = " Installs a preselected set of OpenERP "
" applications which will help you manage your association "
" more efficiently. " ) ,
2010-08-04 13:56:17 +00:00
' auction ' : fields . boolean ( ' Auction Houses ' ,
2010-01-24 18:05:52 +00:00
help = " Installs a preselected set of OpenERP "
" applications selected to help you manage your auctions "
" as well as the business processes around them. " ) ,
2010-01-06 13:34:05 +00:00
}
2010-04-30 06:53:45 +00:00
2010-08-09 08:17:32 +00:00
def _if_knowledge ( self , cr , uid , ids , context = None ) :
if self . pool . get ( ' res.users ' ) . browse ( cr , uid , uid , context = context ) \
. view == ' simple ' :
return [ ' document_ftp ' ]
return None
2010-05-10 07:06:07 +00:00
2010-09-03 06:17:18 +00:00
def _if_misc_tools ( self , cr , uid , ids , context = None ) :
2010-10-09 16:01:43 +00:00
return [ ' profile_tools ' ]
2010-09-03 06:17:18 +00:00
2010-09-14 13:59:12 +00:00
def onchange_moduleselection ( self , cr , uid , ids , * args , * * kargs ) :
value = { }
# Calculate progress
2010-08-09 11:01:10 +00:00
closed , total = self . get_current_progress ( cr , uid )
progress = round ( 100. * closed / ( total + len ( filter ( None , args ) ) ) )
2010-09-14 13:59:12 +00:00
value . update ( { ' progress ' : progress } )
2010-08-09 11:01:10 +00:00
if progress < 10. :
progress = 10.
2011-03-01 07:21:34 +00:00
2010-09-14 13:59:12 +00:00
return { ' value ' : value }
2011-03-01 07:21:34 +00:00
2011-03-16 12:03:38 +00:00
def default_get ( self , cr , uid , fields_list , context = None ) :
#Skipping default value as checked for main application, if already installed
return super ( osv . osv_memory , self ) . default_get (
cr , uid , fields_list , context = context )
def fields_get ( self , cr , uid , fields = None , context = None , write_access = True ) :
#Skipping readonly value for main application, if already installed
return super ( osv . osv_memory , self ) . fields_get (
cr , uid , fields , context , write_access )
2011-03-01 07:21:34 +00:00
def execute ( self , cr , uid , ids , context = None ) :
if context is None :
context = { }
2011-04-27 13:29:22 +00:00
module_pool = self . pool . get ( ' ir.module.module ' )
2011-03-01 07:21:34 +00:00
modules_selected = [ ]
datas = self . read ( cr , uid , ids , context = context ) [ 0 ]
2011-04-27 13:29:22 +00:00
for mod in datas . keys ( ) :
if mod in ( ' id ' , ' progress ' ) :
continue
2011-03-01 07:21:34 +00:00
if datas [ mod ] == 1 :
modules_selected . append ( mod )
2011-04-27 13:29:22 +00:00
module_ids = module_pool . search ( cr , uid , [ ( ' name ' , ' in ' , modules_selected ) ] , context = context )
for module in module_pool . browse ( cr , uid , module_ids , context = context ) :
if module . state == ' uninstalled ' :
module_pool . state_update ( cr , uid , [ module . id ] , ' to install ' , [ ' uninstalled ' ] , context )
2011-03-30 09:57:56 +00:00
cr . commit ( )
new_db , self . pool = pooler . restart_pool ( cr . dbname , update_module = True )
2011-04-27 13:29:22 +00:00
elif module . state == ' installed ' :
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, ))
return
2011-04-07 10:45:27 +00:00
2010-01-06 13:34:05 +00:00
base_setup_installer ( )
2011-04-07 10:45:27 +00:00
#Migrate data from another application Conf wiz
class migrade_application_installer_modules ( osv . osv_memory ) :
_name = ' migrade.application.installer.modules '
_inherit = ' res.config.installer '
_columns = {
' import_saleforce ' : fields . boolean ( ' Import Saleforce ' ,
help = " For Import Saleforce " ) ,
' import_sugarcrm ' : fields . boolean ( ' Import Sugarcrm ' ,
help = " For Import Sugarcrm " ) ,
' sync_google_contact ' : fields . boolean ( ' Sync Google Contact ' ,
help = " For Sync Google Contact " ) ,
' quickbooks_ippids ' : fields . boolean ( ' Quickbooks Ippids ' ,
help = " For Quickbooks Ippids " ) ,
}
migrade_application_installer_modules ( )
2011-04-07 13:29:30 +00:00
class product_installer ( osv . osv_memory ) :
_name = ' product.installer '
_inherit = ' res.config '
_columns = {
' customers ' : fields . selection ( [ ( ' create ' , ' Create ' ) , ( ' import ' , ' Import ' ) ] , ' Customers ' , size = 32 , required = True , help = " Import or create customers " ) ,
}
_defaults = {
' customers ' : ' create ' ,
}
def execute ( self , cr , uid , ids , context = None ) :
if context is None :
context = { }
data_obj = self . pool . get ( ' ir.model.data ' )
val = self . browse ( cr , uid , ids , context = context ) [ 0 ]
if val . customers == ' create ' :
id2 = data_obj . _get_id ( cr , uid , ' base ' , ' view_partner_form ' )
if id2 :
id2 = data_obj . browse ( cr , uid , id2 , context = context ) . res_id
return {
' view_type ' : ' form ' ,
' view_mode ' : ' form ' ,
' res_model ' : ' res.partner ' ,
' views ' : [ ( id2 , ' form ' ) ] ,
' type ' : ' ir.actions.act_window ' ,
' target ' : ' current ' ,
' nodestroy ' : False ,
}
if val . customers == ' import ' :
return { ' type ' : ' ir.actions.act_window ' }
product_installer ( )
2011-04-12 09:09:20 +00:00
# Define default users preferences config wiz
def _lang_get ( self , cr , uid , context = None ) :
obj = self . pool . get ( ' res.lang ' )
ids = obj . search ( cr , uid , [ ( ' translatable ' , ' = ' , True ) ] )
res = obj . read ( cr , uid , ids , [ ' code ' , ' name ' ] , context = context )
res = [ ( r [ ' code ' ] , r [ ' name ' ] ) for r in res ]
return res
def _tz_get ( self , cr , uid , context = None ) :
return [ ( x , x ) for x in pytz . all_timezones ]
class user_preferences_config ( osv . osv_memory ) :
_name = ' user.preferences.config '
_inherit = ' res.config '
_columns = {
' context_tz ' : fields . selection ( _tz_get , ' Timezone ' , size = 64 ,
help = " Set default for new user ' s timezone, used to perform timezone conversions "
" between the server and the client. " ) ,
' context_lang ' : fields . selection ( _lang_get , ' Language ' , required = True ,
help = " Sets default language for the new user ' s user interface, when UI "
" translations are available " ) ,
' view ' : fields . selection ( [ ( ' simple ' , ' Simplified ' ) ,
( ' extended ' , ' Extended ' ) ] ,
' Interface ' , required = True ) ,
' menu_tips ' : fields . boolean ( ' Menu Tips ' , help = " Check out this box if you want to always display tips on each menu action " ) ,
}
_defaults = {
' view ' : lambda self , cr , uid , * args : self . pool . get ( ' res.users ' ) . browse ( cr , uid , uid ) . view or ' simple ' ,
' context_lang ' : ' en_US ' ,
' menu_tips ' : True
}
def execute ( self , cr , uid , ids , context = None ) :
for o in self . browse ( cr , uid , ids , context = context ) :
ir_values_obj = self . pool . get ( ' ir.values ' )
ir_values_obj . set ( cr , uid , ' default ' , False , ' context_tz ' , [ ' res.users ' ] , o . context_tz )
ir_values_obj . set ( cr , uid , ' default ' , False , ' context_lang ' , [ ' res.users ' ] , o . context_lang )
ir_values_obj . set ( cr , uid , ' default ' , False , ' view ' , [ ' res.users ' ] , o . view )
ir_values_obj . set ( cr , uid , ' default ' , False , ' menu_tips ' , [ ' res.users ' ] , o . menu_tips )
return { }
user_preferences_config ( )
2011-04-07 10:45:27 +00:00
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: