1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
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.
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.
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/>.
20 ##############################################################################
22 from caldav import common
23 from dateutil.rrule import *
24 from osv import fields, osv
31 from tools.translate import _
33 AVAILABLE_PRIORITIES = [
41 class crm_phonecall_categ(osv.osv):
42 _name = "crm.phonecall.categ"
43 _description = "Phonecall Categories"
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'),
50 'probability': lambda *args: 0.0
54 class crm_phonecall(osv.osv):
55 _name = "crm.phonecall"
56 _description = "Phonecall Cases"
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'),
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)
80 'name': msg['Subject'],
81 'email_from': msg['From'],
82 'email_cc': msg['Cc'],
84 'description': msg_body['body'],
85 'history_line': [(0, 0, {'description': msg_body['body'], 'email': msg['From'] })],
87 res = mailgate_obj.partner_get(cr, uid, msg['From'])
90 res = self.create(cr, uid, data)