2010-05-05 09:18:51 +00:00
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 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 operator import itemgetter
from osv import osv , fields
import netsvc
import tools
2010-05-05 13:33:42 +00:00
from tools import misc
2010-05-05 09:18:51 +00:00
class base_gtkcontactform ( osv . osv_memory ) :
"""
"""
_name = ' base.gtkcontactform '
_inherit = ' res.config '
logger = netsvc . Logger ( )
def default_get ( self , cr , uid , fields_list = None , context = None ) :
''' set email and phone number selected in the previous company information
form '''
defaults = super ( base_gtkcontactform , self ) \
. default_get ( cr , uid , fields_list = fields_list , context = context )
company_id = self . pool . get ( ' base.setup.company ' ) . search ( cr , uid , [ ] )
2010-05-11 09:40:59 +00:00
company = self . pool . get ( ' base.setup.company ' ) . read ( cr , uid , company_id )
company = company and company [ 0 ] or False
if company :
defaults . update ( { ' email ' : company . get ( ' email ' , ' ' ) ,
2010-05-05 09:18:51 +00:00
' phone ' : company . get ( ' phone ' , ' ' ) } )
return defaults
_columns = {
2010-05-12 14:07:19 +00:00
' name ' : fields . char ( ' Your Name ' , size = 64 ) ,
2010-05-05 09:18:51 +00:00
' job ' : fields . char ( ' Job Title ' , size = 64 , ) ,
2010-05-12 14:07:19 +00:00
' email ' : fields . char ( ' E-mail ' , size = 64 ) ,
' phone ' : fields . char ( ' Phone ' , size = 64 ) ,
2010-05-05 09:18:51 +00:00
' total_employees ' : fields . selection ( [ ( ' 1-5 ' , ' 1-5 ' ) , ( ' 5-20 ' , ' 5-20 ' ) , ( ' 20-100 ' , ' 20-100 ' ) , ( ' 100-500 ' , ' 100-500 ' ) , ( ' 500 ' , ' 500+ ' ) ] , ' No Of Employees ' , size = 32 ) ,
' industry ' : fields . selection ( [ ( ' apparel ' , ' Apparel ' ) , ( ' banking ' , ' Banking ' ) , ( ' biotechnology ' , ' Biotechnology ' ) , ( ' chemicals ' , ' Chemicals ' ) , ( ' communications ' , ' Communications ' ) ,
( ' construction ' , ' Construction ' ) , ( ' consulting ' , ' Consulting ' ) , ( ' education ' , ' Education ' ) , ( ' electronics ' , ' Electronics ' ) , ( ' energy ' , ' Energy ' ) , ( ' engineering ' , ' Engineering ' ) ,
( ' entertainment ' , ' Entertainment ' ) , ( ' environmental ' , ' Environmental ' ) , ( ' finance ' , ' Finance ' ) , ( ' government ' , ' Government ' ) , ( ' healthcare ' , ' Healthcare ' ) , ( ' hospitality ' , ' Hospitality ' ) ,
( ' insurance ' , ' Insurance ' ) , ( ' machinery ' , ' Machinery ' ) , ( ' manufacturing ' , ' Manufacturing ' ) , ( ' media ' , ' Media ' ) , ( ' notforprofit ' , ' Not For Profit ' ) ,
( ' recreation ' , ' Recreation ' ) , ( ' retail ' , ' Retail ' ) , ( ' shipping ' , ' Shipping ' ) , ( ' technology ' , ' Technology ' ) , ( ' telecommunications ' , ' Telecommunications ' ) ,
( ' transportation ' , ' Transportation ' ) , ( ' utilities ' , ' Utilities ' ) , ( ' other ' , ' Other ' ) ,
] , ' Industry ' , size = 32 ) ,
' use_openerp ' : fields . boolean ( ' We plan to use OpenERP ' ) ,
' already_using_openerp ' : fields . boolean ( ' Already using OpenERP ' ) ,
' sell_openerp ' : fields . boolean ( ' Plan to sell OpenERP ' ) ,
' already_selling__openerp ' : fields . boolean ( ' Already selling OpenERP ' ) ,
' features ' : fields . boolean ( ' The features of OpenERP ' ) ,
' saas ' : fields . boolean ( ' OpenERP Online Solutions (SaaS) ' ) ,
' partners_program ' : fields . boolean ( ' OpenERP Partners Program (for integrators) ' ) ,
' support ' : fields . boolean ( ' Support and Maintenance Solutions ' ) ,
' training ' : fields . boolean ( ' OpenERP Training Program ' ) ,
' other ' : fields . boolean ( ' Other ' ) ,
' ebook ' : fields . boolean ( ' ebook ' ) ,
2010-05-13 11:50:52 +00:00
' updates ' : fields . boolean ( ' Updates ' ) ,
2010-05-05 09:18:51 +00:00
}
def execute ( self , cr , uid , ids , context = None ) :
2010-05-18 12:22:20 +00:00
if context is None :
context = { }
2010-05-19 15:57:31 +00:00
2010-05-18 12:22:20 +00:00
company_id = self . pool . get ( ' base.setup.company ' ) . search ( cr , uid , [ ] , context = context )
company_data = self . pool . get ( ' base.setup.company ' ) . read ( cr , uid , company_id , context = context )
company_data = company_data and company_data [ 0 ] or { }
2010-05-18 05:33:18 +00:00
country = ' '
2010-06-04 06:21:45 +00:00
2010-05-18 12:22:20 +00:00
if company_data . get ( ' country_id ' , False ) :
country = self . pool . get ( ' res.country ' ) . read ( cr , uid , company_data [ ' country_id ' ] , [ ' name ' ] , context = context ) [ ' name ' ]
2010-06-04 06:21:45 +00:00
2010-05-18 12:22:20 +00:00
for res in self . read ( cr , uid , ids , context = context ) :
2010-05-05 13:33:42 +00:00
email = res . get ( ' email ' , ' ' )
2010-05-18 12:22:20 +00:00
result = " \n company: " + tools . ustr ( company_data . get ( ' name ' , ' ' ) )
result + = " \n name: " + tools . ustr ( res . get ( ' name ' , ' ' ) )
2010-05-19 14:59:40 +00:00
result + = " \n job: " + tools . ustr ( res . get ( ' job ' , ' ' ) )
2010-05-05 13:33:42 +00:00
result + = " \n phone: " + str ( res . get ( ' phone ' , ' ' ) )
2010-05-18 12:22:20 +00:00
result + = " \n city: " + tools . ustr ( company_data . get ( ' city ' , ' ' ) )
2010-05-05 13:33:42 +00:00
result + = " \n country: " + str ( country )
2010-05-18 12:22:20 +00:00
result + = " \n industry: " + tools . ustr ( res . get ( ' industry ' , ' ' ) )
2010-05-05 13:33:42 +00:00
result + = " \n total_employees: " + str ( res . get ( ' total_employees ' , ' ' ) )
result + = " \n plan_use: " + str ( res . get ( ' use_openerp ' , False ) )
2010-05-17 12:59:18 +00:00
result + = " \n already_using_openerp: " + str ( res . get ( ' already_using_openerp ' , False ) )
2010-05-05 13:33:42 +00:00
result + = " \n sell_openerp: " + str ( res . get ( ' sell_openerp ' , False ) )
2010-05-17 12:59:18 +00:00
result + = " \n already_selling__openerp: " + str ( res . get ( ' already_selling__openerp ' , False ) )
result + = " \n features: " + str ( res . get ( ' features ' , False ) )
result + = " \n saas: " + str ( res . get ( ' saas ' , False ) )
result + = " \n partners_program: " + str ( res . get ( ' partners_program ' , False ) )
result + = " \n support: " + str ( res . get ( ' support ' , False ) )
result + = " \n training: " + str ( res . get ( ' training ' , False ) )
result + = " \n updates: " + str ( res . get ( ' updates ' , False ) )
result + = " \n contact_me: " + str ( res . get ( ' contact_me ' , False ) )
2010-05-05 13:33:42 +00:00
result + = " \n ebook: " + str ( res . get ( ' ebook ' , False ) )
result + = " \n gtk: " + str ( True )
misc . upload_data ( email , result , type = ' SURVEY ' )
2010-05-05 09:18:51 +00:00
base_gtkcontactform ( )