2012-02-29 09:50:21 +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 osv import fields , osv
class crm_configuration ( osv . osv_memory ) :
2012-03-05 05:11:33 +00:00
_inherit = ' res.config.settings '
2012-02-29 09:50:21 +00:00
_columns = {
2012-03-02 11:39:31 +00:00
' module_crm_caldav ' : fields . boolean ( " Caldav Synchronization " ,
help = """ Allows Caldav features in Meeting, Share meeting with other calendar clients like sunbird.
2012-03-02 08:50:38 +00:00
It installs crm_caldav module . """ ),
2012-03-03 07:19:07 +00:00
' fetchmail_crm ' : fields . boolean ( " Lead/Opportunity mail gateway " , help = " Allows you to configure your incoming mail server. And creates leads for your mails. " ) ,
2012-02-29 09:50:21 +00:00
' server ' : fields . char ( ' Server Name ' , size = 256 ) ,
' port ' : fields . integer ( ' Port ' ) ,
' type ' : fields . selection ( [
( ' pop ' , ' POP Server ' ) ,
( ' imap ' , ' IMAP Server ' ) ,
( ' local ' , ' Local Server ' ) ,
] , ' Server Type ' ) ,
' is_ssl ' : fields . boolean ( ' SSL/TLS ' , help = " Connections are encrypted with SSL/TLS through a dedicated port (default: IMAPS=993, POP=995) " ) ,
' user ' : fields . char ( ' Username ' , size = 256 ) ,
' password ' : fields . char ( ' Password ' , size = 1024 ) ,
2012-03-02 08:48:46 +00:00
' module_import_sugarcrm ' : fields . boolean ( " SugarCRM Import " ,
2012-03-02 11:39:31 +00:00
help = """ Import SugarCRM Leads, Opportunities, Users, Accounts, Contacts, Employees, Meetings, Phonecalls, Emails, and Project, Project Tasks Data.
2012-03-01 11:38:35 +00:00
It installs import_sugarcrm module .
""" ),
2012-03-02 08:48:46 +00:00
' module_import_google ' : fields . boolean ( " Google Import " ,
2012-03-01 11:38:35 +00:00
help = """
2012-03-02 08:48:46 +00:00
Import google contact in partner address and add google calendar events details in Meeting .
2012-03-01 11:38:35 +00:00
It installs import_google module .
""" ),
2012-03-01 12:03:27 +00:00
' module_wiki_sale_faq ' : fields . boolean ( " Install a sales FAQ? " ,
2012-03-01 11:38:35 +00:00
help = """
It provides demo data , thereby creating a Wiki Group and a Wiki Page for Wiki Sale FAQ .
It installs wiki_sale_faq module .
""" ),
2012-03-01 12:03:27 +00:00
' module_base_contact ' : fields . boolean ( " Manage a several address per customer " ,
2012-03-01 11:38:35 +00:00
help = """
It lets you define :
* contacts unrelated to a partner ,
* contacts working at several addresses ( possibly for different partners ) ,
2012-03-02 11:39:31 +00:00
* contacts with possibly different functions for each of its job ' s addresses.
2012-03-01 11:38:35 +00:00
It installs base_contact module .
""" ),
2012-03-01 12:03:27 +00:00
' module_google_map ' : fields . boolean ( " Google maps on customer " ,
2012-03-01 11:38:35 +00:00
help = """
2012-03-02 11:39:31 +00:00
Allows you to locate customer on Google Map .
2012-03-01 11:38:35 +00:00
It installs google_map module .
""" ),
2012-02-29 09:50:21 +00:00
}
2012-03-01 11:38:35 +00:00
2012-02-29 09:50:21 +00:00
_defaults = {
' type ' : ' pop ' ,
}
2012-03-03 07:19:07 +00:00
2012-02-29 09:50:21 +00:00
def get_default_email_configurations ( self , cr , uid , ids , context = None ) :
ir_values_obj = self . pool . get ( ' ir.values ' )
2012-03-03 07:19:07 +00:00
fetchmail_obj = self . pool . get ( ' fetchmail.server ' )
2012-02-29 09:50:21 +00:00
result = { }
2012-03-03 07:19:07 +00:00
server_ids = fetchmail_obj . search ( cr , uid , [ ( ' name ' , ' = ' , ' Incoming Leads ' ) , ( ' state ' , ' = ' , ' done ' ) ] )
if server_ids :
result . update ( { ' fetchmail_crm ' : True } )
for val in ir_values_obj . get ( cr , uid , ' default ' , False , [ ' fetchmail.server ' ] ) :
result . update ( { val [ 1 ] : val [ 2 ] } )
2012-02-29 09:50:21 +00:00
return result
def onchange_server_type ( self , cr , uid , ids , server_type = False , ssl = False ) :
port = 0
values = { }
if server_type == ' pop ' :
port = ssl and 995 or 110
elif server_type == ' imap ' :
port = ssl and 993 or 143
else :
values [ ' server ' ] = ' '
values [ ' port ' ] = port
return { ' value ' : values }
def set_email_configurations ( self , cr , uid , ids , vals , context = None ) :
model_obj = self . pool . get ( ' ir.model ' )
fetchmail_obj = self . pool . get ( ' fetchmail.server ' )
ir_values_obj = self . pool . get ( ' ir.values ' )
2012-03-02 08:50:38 +00:00
object_id = model_obj . search ( cr , uid , [ ( ' model ' , ' = ' , ' crm.lead ' ) ] )
2012-03-03 07:19:07 +00:00
if vals . get ( ' fetchmail_crm ' ) and object_id :
2012-02-29 09:50:21 +00:00
fetchmail_vals = {
' name ' : ' Incoming Leads ' ,
2012-03-02 08:50:38 +00:00
' object_id ' : object_id [ 0 ] ,
2012-02-29 09:50:21 +00:00
' server ' : vals . get ( ' server ' ) ,
' port ' : vals . get ( ' port ' ) ,
' is_ssl ' : vals . get ( ' is_ssl ' ) ,
' type ' : vals . get ( ' type ' ) ,
' user ' : vals . get ( ' user ' ) ,
' password ' : vals . get ( ' password ' )
}
2012-03-03 07:19:07 +00:00
server_ids = fetchmail_obj . search ( cr , uid , [ ( ' name ' , ' = ' , ' Incoming Leads ' ) , ( ' state ' , ' != ' , ' done ' ) ] )
if not server_ids :
2012-03-02 11:39:31 +00:00
server_ids = [ fetchmail_obj . create ( cr , uid , fetchmail_vals , context = context ) ]
2012-02-29 09:50:21 +00:00
else :
2012-03-02 11:39:31 +00:00
server_ids = fetchmail_obj . search ( cr , uid , [ ( ' name ' , ' = ' , ' Incoming Leads ' ) ] , context = context )
fetchmail_obj . write ( cr , uid , server_ids , fetchmail_vals , context = context )
fetchmail_obj . button_confirm_login ( cr , uid , server_ids , context = None )
2012-02-29 09:50:21 +00:00
ir_values_obj . set ( cr , uid , ' default ' , False , ' server ' , [ ' fetchmail.server ' ] , fetchmail_vals . get ( ' server ' ) )
ir_values_obj . set ( cr , uid , ' default ' , False , ' port ' , [ ' fetchmail.server ' ] , fetchmail_vals . get ( ' port ' ) )
ir_values_obj . set ( cr , uid , ' default ' , False , ' is_ssl ' , [ ' fetchmail.server ' ] , fetchmail_vals . get ( ' is_ssl ' ) )
ir_values_obj . set ( cr , uid , ' default ' , False , ' type ' , [ ' fetchmail.server ' ] , fetchmail_vals . get ( ' type ' ) )
ir_values_obj . set ( cr , uid , ' default ' , False , ' user ' , [ ' fetchmail.server ' ] , fetchmail_vals . get ( ' user ' ) )
ir_values_obj . set ( cr , uid , ' default ' , False , ' password ' , [ ' fetchmail.server ' ] , fetchmail_vals . get ( ' password ' ) )
2012-03-03 07:19:07 +00:00
else :
server_ids = fetchmail_obj . search ( cr , uid , [ ( ' name ' , ' = ' , ' Incoming Leads ' ) , ( ' state ' , ' = ' , ' done ' ) ] )
fetchmail_obj . set_draft ( cr , uid , server_ids , context = None )
crm_configuration ( )
2012-02-29 09:50:21 +00:00
2012-03-03 07:19:07 +00:00
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: