1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 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 osv import osv, fields
23 from tools.translate import _
27 class crm_phonecall2phonecall(osv.osv_memory):
28 _name = 'crm.phonecall2phonecall'
29 _description = 'Phonecall To Phonecall'
32 'name' : fields.char('Call summary', size=64, required=True, select=1),
33 'user_id' : fields.many2one('res.users',"Assign To"),
34 'contact_name':fields.char('Contact', size=64),
35 'phone':fields.char('Phone', size=64),
36 'categ_id': fields.many2one('crm.case.categ', 'Category', \
37 domain="['|',('section_id','=',False),('section_id','=',section_id),\
38 ('object_id.model', '=', 'crm.phonecall')]"),
39 'date': fields.datetime('Date'),
40 'section_id':fields.many2one('crm.case.section','Sales Team'),
41 'action': fields.selection([('schedule','Schedule a call'), ('log','Log a call')], 'Action', required=True),
42 'partner_id' : fields.many2one('res.partner', "Partner"),
43 'note':fields.text('Note')
47 def action_cancel(self, cr, uid, ids, context=None):
49 Closes Phonecall to Phonecall form
51 return {'type':'ir.actions.act_window_close'}
53 def action_schedule(self, cr, uid, ids, context=None):
57 phonecall = self.pool.get('crm.phonecall')
58 phonecall_ids = context and context.get('active_ids') or []
59 for this in self.browse(cr, uid, ids, context=context):
60 phocall_ids = phonecall.schedule_another_phonecall(cr, uid, phonecall_ids, this.date, this.name, \
61 this.user_id and this.user_id.id or False, \
62 this.section_id and this.section_id.id or False, \
63 this.categ_id and this.categ_id.id or False, \
64 action=this.action, context=context)
66 return phonecall.redirect_phonecall_view(cr, uid, phocall_ids[phonecall_ids[0]], context=context)
68 def default_get(self, cr, uid, fields, context=None):
70 This function gets default values
73 res = super(crm_phonecall2phonecall, self).default_get(cr, uid, fields, context=context)
74 record_id = context and context.get('active_id', False) or False
75 res.update({'action': 'schedule', 'date': time.strftime('%Y-%m-%d %H:%M:%S')})
77 phonecall = self.pool.get('crm.phonecall').browse(cr, uid, record_id, context=context)
80 data_obj = self.pool.get('ir.model.data')
81 res_id = data_obj._get_id(cr, uid, 'crm', 'categ_phone2')
83 categ_id = data_obj.browse(cr, uid, res_id, context=context).res_id
86 res.update({'name': phonecall.name})
87 if 'user_id' in fields:
88 res.update({'user_id': phonecall.user_id and phonecall.user_id.id or False})
90 res.update({'date': phonecall.date})
91 if 'section_id' in fields:
92 res.update({'section_id': phonecall.section_id and phonecall.section_id.id or False})
93 if 'categ_id' in fields:
94 res.update({'categ_id': categ_id})
95 if 'partner_id' in fields:
96 res.update({'partner_id': phonecall.partner_id and phonecall.partner_id.id or False})
99 crm_phonecall2phonecall()
101 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: