[REM]:remove the assing button for all cases
[odoo/odoo.git] / addons / crm / crm_phonecall.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2009 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 from caldav import common
23 from dateutil.rrule import *
24 from osv import fields, osv
25 import  datetime
26 import base64
27 import re
28 import time
29 import tools
30
31 from tools.translate import _
32
33 AVAILABLE_PRIORITIES = [
34     ('5','Lowest'),
35     ('4','Low'),
36     ('3','Normal'),
37     ('2','High'),
38     ('1','Highest')
39 ]
40
41 class crm_phonecall_categ(osv.osv):
42     _name = "crm.phonecall.categ"
43     _description = "Phonecall Categories"
44     _columns = {
45             'name': fields.char('Category Name', size=64, required=True),
46             'probability': fields.float('Probability (%)', required=True),
47             'section_id': fields.many2one('crm.case.section', 'Case Section'),
48     }
49     _defaults = {
50         'probability': lambda *args: 0.0
51     }
52 crm_phonecall_categ()
53
54 class crm_phonecall(osv.osv):
55     _name = "crm.phonecall"
56     _description = "Phonecall Cases"
57     _order = "id desc"
58     _inherit = 'crm.case'
59     _columns = {
60         'duration': fields.float('Duration'),
61         'categ_id': fields.many2one('crm.phonecall.categ', 'Category', domain="[('section_id','=',section_id)]"),
62         'partner_phone': fields.char('Phone', size=32),
63         'partner_mobile': fields.char('Mobile', size=32),
64         'som': fields.many2one('res.partner.som', 'State of Mind', help="The minds states allow to define a value scale which represents" \
65                                                                    "the partner mentality in relation to our services.The scale has" \
66                                                                    "to be created with a factor for each level from 0 (Very dissatisfied) to 10 (Extremely satisfied)."),
67         'priority': fields.selection(AVAILABLE_PRIORITIES, 'Priority'),
68         'canal_id': fields.many2one('res.partner.canal', 'Channel',help="The channels represent the different communication modes available with the customer." \
69                                                                 " With each commercial opportunity, you can indicate the canall which is this opportunity source."),
70         'probability': fields.float('Probability (%)'),
71         'planned_revenue': fields.float('Planned Revenue'),
72         'date_closed': fields.datetime('Closed', readonly=True),
73         'opportunity_id':fields.many2one ('crm.opportunity', 'Opportunity'),        
74     }
75
76     def msg_new(self, cr, uid, msg):
77         mailgate_obj = self.pool.get('mail.gateway')
78         msg_body = mailgate_obj.msg_body_get(msg)
79         data = {
80             'name': msg['Subject'],
81             'email_from': msg['From'],
82             'email_cc': msg['Cc'],
83             'user_id': False,
84             'description': msg_body['body'],
85             'history_line': [(0, 0, {'description': msg_body['body'], 'email': msg['From'] })],
86         }
87         res = mailgate_obj.partner_get(cr, uid, msg['From'])
88         if res:
89             data.update(res)
90         res = self.create(cr, uid, data)
91         return res
92
93 crm_phonecall()
94