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
##############################################################################
22
from osv import osv, fields
23
from tools.translate import _
25
class hr_recruitment_partner_create(osv.osv_memory):
26
_name = 'hr.recruitment.partner.create'
27
_description = 'Create Partner from job application'
29
'close': fields.boolean('Close job request'),
32
def view_init(self, cr , uid , fields_list, context=None):
33
case_obj = self.pool.get('hr.applicant')
36
for case in case_obj.browse(cr, uid, context['active_ids'], context=context):
38
raise osv.except_osv(_('Error !'),
39
_('A partner is already defined on this job request.'))
42
def make_order(self, cr, uid, ids, context=None):
43
mod_obj = self.pool.get('ir.model.data')
44
partner_obj = self.pool.get('res.partner')
45
contact_obj = self.pool.get('res.partner.address')
46
case_obj = self.pool.get('hr.applicant')
50
data = self.read(cr, uid, ids, [], context=context)[0]
51
result = mod_obj._get_id(cr, uid, 'base', 'view_res_partner_filter')
52
res = mod_obj.read(cr, uid, result, ['res_id'], context=context)
54
for case in case_obj.browse(cr, uid, context['active_ids'], context=context):
55
partner_id = partner_obj.search(cr, uid, [('name', '=', case.partner_name or case.name)], context=context)
57
raise osv.except_osv(_('Error !'),_('A partner is already existing with the same name.'))
58
partner_id = partner_obj.create(cr, uid, {
59
'name': case.partner_name or case.name,
60
'user_id': case.user_id.id,
61
'comment': case.description,
63
contact_id = contact_obj.create(cr, uid, {
64
'partner_id': partner_id,
65
'name': case.partner_name,
66
'phone': case.partner_phone,
67
'mobile': case.partner_mobile,
68
'email': case.email_from
71
case_obj.write(cr, uid, case.id, {
72
'partner_id': partner_id,
73
'partner_address_id': contact_id
76
case_obj.case_close(cr, uid, context['active_ids'])
81
'view_mode': 'form,tree',
82
'res_model': 'res.partner',
83
'res_id': int(partner_id),
85
'type': 'ir.actions.act_window',
86
'search_view_id': res['res_id']
89
hr_recruitment_partner_create()
91
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
b'\\ No newline at end of file'