** added menu data files for each sections which will be loaded on configuration...
[odoo/odoo.git] / addons / crm_configuration / crm_config.py
1 # -*- encoding: utf-8 -*-
2 ##############################################################################
3 #
4 # Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
5 #
6 # $Id$
7 #
8 # WARNING: This program as such is intended to be used by professional
9 # programmers who take the whole responsability of assessing all potential
10 # consequences resulting from its eventual inadequacies and bugs
11 # End users who are looking for a ready-to-use solution with commercial
12 # garantees and support are strongly adviced to contract a Free Software
13 # Service Company
14 #
15 # This program is Free Software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License
17 # as published by the Free Software Foundation; either version 2
18 # of the License, or (at your option) any later version.
19 #
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
28 #
29 ##############################################################################
30
31 import time
32 import tools
33 from osv import fields,osv,orm
34 import os
35 import mx.DateTime
36 import base64
37
38 #AVAILABLE_STATES = [
39 #    ('draft','Unreviewed'),
40 #    ('open','Open'),
41 #    ('cancel', 'Refuse Bug'),
42 #    ('done', 'Done'),
43 #    ('pending','Pending')
44 #]
45 class crm_case_category2(osv.osv):
46     _name = "crm.case.category2"
47     _description = "Category2 of case"
48     _rec_name = "name"
49     _columns = {
50         'name': fields.char('Case Category2 Name', size=64, required=True),
51         'section_id': fields.many2one('crm.case.section', 'Case Section'),
52     }
53 crm_case_category2()
54
55 class crm_case_stage(osv.osv):
56     _name = "crm.case.stage"
57     _description = "Stage of case"
58     _rec_name = 'name'
59     _columns = {
60         'name': fields.char('Stage Name', size=64, required=True),
61         'section_id': fields.many2one('crm.case.section', 'Case Section'),
62     }
63 crm_case_stage()
64
65 class crm_cases(osv.osv):
66     _name = "crm.case"
67     _inherit = "crm.case"
68     _columns = {
69         'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id)]"),
70         'category2_id': fields.many2one('crm.case.category2','Category Name', domain="[('section_id','=',section_id)]"),
71         'duration': fields.float('Duration'),
72         'note': fields.text('Note'),
73         'partner_name': fields.char('Employee Name', size=64),
74         'partner_name2': fields.char('Employee Email', size=64),
75         'partner_phone': fields.char('Phone', size=16),
76         'partner_mobile': fields.char('Mobile', size=16),
77     }
78
79 crm_cases()
80
81 class crm_menu_config_wizard(osv.osv_memory):
82     _name='crm.menu.config_wizard'
83     _columns = {
84         'name':fields.char('Name', size=64),
85         'meeting' : fields.boolean('Calendar of Meetings', help="Manages the calendar of meetings of the users."),
86         'lead' : fields.boolean('Leads', help="Allows you to track and manage leads which are pre-sales requests, the very first contact with a customer request."),
87         'opportunity' : fields.boolean('Business Opportunities', help="Tracks identified business opportunities for your sales pipeline."),
88         'jobs' : fields.boolean('Jobs Hiring Process', help="Help you to organise the jobs hiring process: evaluation, meetings, email integration..."),
89         'bugs' : fields.boolean('Bug Tracking', help="Used by companies to track bugs and support requests on softwares"),
90         'fund' : fields.boolean('Fund Raising Operations', help="This may help associations in their fund raising process and tracking."),
91     }
92     _defaults = {
93         'meeting': lambda *args: True,
94         'jobs': lambda *args: True,
95         'opportunity': lambda *args: True,
96     }
97     def action_create(self, cr, uid, ids, *args):
98         for res in self.read(cr,uid,ids):
99             res.__delitem__('id')
100     #        'update'
101             for section in res :
102                 if res[section]:
103                     file_name = 'crm_'+section+'_menu.xml'
104                     try:
105                         tools.convert_xml_import(cr, 'crm_configuration', tools.file_open(os.path.join('crm_configuration',file_name )),  {}, 'init', *args)
106                     except Exception, e:
107                         raise osv.except_osv('Error !', e)
108                         
109         return {
110                 'view_type': 'form',
111                 "view_mode": 'form',
112                 'res_model': 'ir.module.module.configuration.wizard',
113                 'type': 'ir.actions.act_window',
114                 'target':'new',
115          }
116     def action_cancel(self,cr,uid,ids,conect=None):
117         return {
118                 'view_type': 'form',
119                 "view_mode": 'form',
120                 'res_model': 'ir.module.module.configuration.wizard',
121                 'type': 'ir.actions.act_window',
122                 'target':'new',
123          }
124         
125 crm_menu_config_wizard()
126
127 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
128