1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Affero General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Affero General Public License for more details.
18 # You should have received a copy of the GNU Affero General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
24 from osv import osv, fields
25 from tools.translate import _
27 class job2phonecall(osv.osv_memory):
28 _name = 'hr.recruitment.job2phonecall'
29 _description = 'Schedule Phone Call'
31 'user_id': fields.many2one('res.users', 'Assign To'),
32 'deadline': fields.datetime('Planned Date'),
33 'note': fields.text('Goals'),
34 'category_id': fields.many2one('crm.case.categ', 'Category', required=True),
37 def _date_user(self, cr, uid, context=None):
38 case_obj = self.pool.get('hr.applicant')
41 case = case_obj.browse(cr, uid, context.get('active_id', False), context=context)
42 return case.user_id and case.user_id.id or False
44 def _date_category(self, cr, uid, context=None):
45 case_obj = self.pool.get('hr.applicant')
48 case = case_obj.browse(cr, uid, context.get('active_id', False), context=context)
49 categ_id = self.pool.get('crm.case.categ').search(cr, uid, [('name','=','Outbound')], context=context)
50 return categ_id and categ_id[0] or case.categ_id and case.categ_id.id or False
52 def _get_note(self, cr, uid, context=None):
53 case_obj = self.pool.get('hr.applicant')
56 case = case_obj.browse(cr, uid, context.get('active_id', False), context=context)
57 return case.description or ''
60 'user_id': _date_user,
61 'category_id': _date_category,
65 def make_phonecall(self, cr, uid, ids, context=None):
66 mod_obj = self.pool.get('ir.model.data')
67 job_case_obj = self.pool.get('hr.applicant')
68 data_obj = self.pool.get('ir.model.data')
69 phonecall_case_obj = self.pool.get('crm.phonecall')
72 form = self.read(cr, uid, ids, [], context=context)[0]
73 result = mod_obj._get_id(cr, uid, 'crm', 'view_crm_case_phonecalls_filter')
74 res = mod_obj.read(cr, uid, result, ['res_id'], context=context)
77 id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_phone_tree_view')
78 id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_phone_form_view')
80 id2 = data_obj.browse(cr, uid, id2, context=context).res_id
82 id3 = data_obj.browse(cr, uid, id3, context=context).res_id
84 for job in job_case_obj.browse(cr, uid, context.get('active_ids', []), context=context):
85 #TODO: Take other info from job
86 new_phonecall_id = phonecall_case_obj.create(cr, uid, {
88 'user_id': form['user_id'],
89 'categ_id': form['category_id'],
90 'description': form['note'],
91 'date': form['deadline'],
92 'description': job.description,
93 'partner_id': job.partner_id.id,
94 'partner_address_id': job.partner_address_id.id,
95 'partner_phone': job.partner_phone,
96 'partner_mobile': job.partner_mobile,
97 'description': job.description,
100 new_phonecall = phonecall_case_obj.browse(cr, uid, new_phonecall_id, context=context)
102 job_case_obj.write(cr, uid, [job.id], vals, context=context)
103 # job_case_obj.case_cancel(cr, uid, [job.id])
104 phonecall_case_obj.case_open(cr, uid, [new_phonecall_id])
107 'name': _('Phone Call'),
109 'view_mode': 'tree,form',
110 'res_model': 'crm.phonecall',
111 'res_id': new_phonecall_id,
112 'views': [(id3,'form'), (id2,'tree'), (False,'calendar'), (False,'graph')],
113 'type': 'ir.actions.act_window',
114 'search_view_id': res['res_id']
119 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: