[IMP] l10n_us: added a minimal set for COT, taxes and fiscal positions. Removed sign...
[odoo/odoo.git] / addons / document_ics / document_ics_config_wizard.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21
22 import time
23 import tools
24 from osv import fields, osv, orm
25 import os
26 import base64
27 import pooler
28
29 SECTION_NAME = {
30     'meeting' : 'Meetings',
31     'lead':'Leads',
32     'opportunity':'Opportunities',
33     'jobs':'Jobs',
34     'bugs':'Bug Tracking',
35     'fund':'Fund Raising',
36     'helpdesk':'HelpDesk',
37     'claims':'Claims',
38     'phonecall':'Phone Calls',
39                 }
40
41 ICS_TAGS = {
42         'summary':'Description',
43         'uid':'Calendar Code' ,
44         'dtstart':'Date' ,
45         'dtend':'Deadline' ,
46         'url':'Partner Email' ,
47         'description':'Your action',
48             }
49
50 class document_ics_crm_wizard(osv.osv_memory):
51     _name='document.ics.crm.wizard'
52     _inherit = 'res.config'
53
54     _columns = {
55         'name':fields.char('Name', size=64),
56         'meeting': fields.boolean('Calendar of Meetings', help="Manages the calendar of meetings of the users."),
57         'lead': fields.boolean('Leads', help="Allows you to track and manage leads which are pre-sales requests or contacts, the very first contact with a customer request."),
58         'opportunity': fields.boolean('Business Opportunities', help="Tracks identified business opportunities for your sales pipeline."),
59         'jobs': fields.boolean('Jobs Hiring Process', help="Helps you to organise the jobs hiring process: evaluation, meetings, email integration..."),
60         'document_ics':fields.boolean('Shared Calendar', help=" Will allow you to synchronise your Open ERP calendars with your phone, outlook, Sunbird, ical, ..."),
61         'bugs': fields.boolean('Bug Tracking', help="Used by companies to track bugs and support requests on software"),
62         'helpdesk': fields.boolean('Helpdesk', help="Manages an Helpdesk service."),
63         'fund': fields.boolean('Fund Raising Operations', help="This may help associations in their fund raising process and tracking."),
64         'claims': fields.boolean('Claims', help="Manages the supplier and customers claims,including your corrective or preventive actions."),
65         'phonecall': fields.boolean('Phone Calls', help="Helps you to encode the result of a phone call or to plan a list of phone calls to process."),
66     }
67     _defaults = {
68         'meeting': lambda *args: True,
69         'opportunity': lambda *args: True,
70         'phonecall': lambda *args: True,
71     }
72
73     def execute(self, cr, uid, ids, context=None):
74         """
75             @param self: The object pointer
76             @param cr: the current row, from the database cursor,
77             @param uid: the current user’s ID for security checks,
78             @param ids: List of Document CRM wizard’s IDs
79             @param context: A standard dictionary for contextual values """
80
81         data = self.read(cr, uid, ids, [], context=context)[0]
82         dir_obj = self.pool.get('document.directory')
83         dir_cont_obj = self.pool.get('document.directory.content')
84         dir_id = dir_obj.search(cr, uid, [('name', '=', 'Calendars')])
85         if dir_id:
86             dir_id = dir_id[0]
87         else:
88             dir_id = dir_obj.create(cr, uid, {'name': 'Calendars' ,'user_id' : uid, 'type': 'directory'})
89         for section in ['meeting', 'lead', 'opportunity', 'jobs', 'bugs', 'fund', \
90                             'helpdesk', 'claims', 'phonecall']:
91             if data[section]:
92                 section_id=self.pool.get('crm.case.section').search(cr, uid, \
93                             [('name', '=', SECTION_NAME[section])])
94                 if section_id:
95                     object_id=self.pool.get('ir.model').search(cr, uid, [('name', '=', 'Case')])[0]
96
97                     vals_cont = {
98                           'name': SECTION_NAME[section],
99                           'sequence': 1,
100                           'directory_id': dir_id,
101                           'suffix': section,
102                           'extension': '.ics',
103                           'ics_object_id': object_id,
104                           'ics_domain': [('section_id', '=', section_id[0])],
105                           'include_name' : False
106                         }
107
108                     content_id = dir_cont_obj.create(cr, uid, vals_cont)
109
110                     ics_obj=self.pool.get('document.directory.ics.fields')
111                     for tag in ['description', 'url', 'summary', 'dtstart', 'dtend', 'uid']:
112                         field_id =  self.pool.get('ir.model.fields').search(cr, uid,\
113                                     [('model_id.name', '=', 'Case'),\
114                                     ('field_description', '=', ICS_TAGS[tag])])[0]
115                         vals_ics = {
116                             'field_id':  field_id ,
117                             'name':  tag ,
118                             'content_id': content_id ,
119                             }
120                         ics_obj.create(cr, uid, vals_ics)
121
122 document_ics_crm_wizard()
123
124 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: