2010-02-28 20:36:51 +00:00
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
##############################################################################
|
|
|
|
|
#
|
|
|
|
|
# OpenERP, Open Source Management Solution
|
|
|
|
|
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
|
|
|
|
#
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
#
|
|
|
|
|
##############################################################################
|
|
|
|
|
|
2010-05-12 08:36:32 +00:00
|
|
|
|
from osv import fields, osv
|
|
|
|
|
from crm import crm
|
2010-02-28 20:36:51 +00:00
|
|
|
|
|
|
|
|
|
AVAILABLE_STATES = [
|
2010-05-14 09:29:24 +00:00
|
|
|
|
('draft', 'New'),
|
|
|
|
|
('open', 'In Progress'),
|
2010-02-28 20:36:51 +00:00
|
|
|
|
('cancel', 'Refused'),
|
|
|
|
|
('done', 'Hired'),
|
2010-05-12 08:36:32 +00:00
|
|
|
|
('pending', 'Pending')
|
2010-02-28 20:36:51 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
AVAILABLE_PRIORITIES = [
|
2010-05-14 09:29:24 +00:00
|
|
|
|
('5', 'Not Good'),
|
|
|
|
|
('4', 'On Average'),
|
|
|
|
|
('3', 'Good'),
|
|
|
|
|
('2', 'Very Good'),
|
2010-05-12 08:36:32 +00:00
|
|
|
|
('1', 'Excellent')
|
2010-02-28 20:36:51 +00:00
|
|
|
|
]
|
|
|
|
|
|
2010-05-11 13:54:14 +00:00
|
|
|
|
class hr_recruitment_stage(osv.osv):
|
|
|
|
|
""" Stage of HR Recruitment """
|
|
|
|
|
|
|
|
|
|
_name = "hr.recruitment.stage"
|
|
|
|
|
_description = "Stage of Recruitment"
|
|
|
|
|
_columns = {
|
2010-05-12 05:56:48 +00:00
|
|
|
|
'name': fields.char('Name', size=64, required=True, translate=True),
|
|
|
|
|
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of stages."),
|
2010-05-11 13:54:14 +00:00
|
|
|
|
'requirements': fields.text('Requirements')
|
|
|
|
|
}
|
|
|
|
|
_defaults = {
|
|
|
|
|
'sequence': 1,
|
|
|
|
|
}
|
|
|
|
|
hr_recruitment_stage()
|
2010-02-28 20:36:51 +00:00
|
|
|
|
|
2010-05-12 08:36:32 +00:00
|
|
|
|
class hr_applicant(osv.osv, crm.crm_case):
|
2010-02-28 20:36:51 +00:00
|
|
|
|
_name = "hr.applicant"
|
2010-05-19 18:32:32 +00:00
|
|
|
|
_description = "Applicant"
|
2010-02-28 20:36:51 +00:00
|
|
|
|
_order = "id desc"
|
2010-05-12 08:36:32 +00:00
|
|
|
|
_inherit ='mailgate.thread'
|
|
|
|
|
|
2010-02-28 20:36:51 +00:00
|
|
|
|
_columns = {
|
2010-05-14 09:29:24 +00:00
|
|
|
|
'active': fields.boolean('Active', help="If the active field is set to false, it will allow you to hide the case without removing it."),
|
|
|
|
|
'description': fields.text('Description'),
|
2010-05-12 08:36:32 +00:00
|
|
|
|
'section_id': fields.many2one('crm.case.section', 'Sales Team', \
|
|
|
|
|
select=True, help='Sales team to which Case belongs to.\
|
2010-05-14 09:29:24 +00:00
|
|
|
|
Define Responsible user and Email account for mail gateway.'),
|
|
|
|
|
'email_from': fields.char('Email', size=128, help="These people will receive email."),
|
2010-05-12 08:36:32 +00:00
|
|
|
|
'email_cc': fields.text('Watchers Emails', size=252 , help="These people\
|
|
|
|
|
will receive a copy of the future" \
|
2010-05-14 09:29:24 +00:00
|
|
|
|
" communication between partner and users by email"),
|
|
|
|
|
'probability': fields.float('Probability'),
|
|
|
|
|
'partner_id': fields.many2one('res.partner', 'Partner'),
|
2010-05-12 08:36:32 +00:00
|
|
|
|
'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \
|
2010-05-14 09:29:24 +00:00
|
|
|
|
domain="[('partner_id','=',partner_id)]"),
|
|
|
|
|
'create_date': fields.datetime('Creation Date' , readonly=True),
|
|
|
|
|
'write_date': fields.datetime('Update Date' , readonly=True),
|
2010-05-12 08:36:32 +00:00
|
|
|
|
'stage_id': fields.many2one ('crm.case.stage', 'Stage', \
|
|
|
|
|
domain="[('section_id','=',section_id),\
|
2010-05-14 09:29:24 +00:00
|
|
|
|
('object_id.model', '=', 'crm.opportunity')]"),
|
|
|
|
|
'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True,
|
2010-05-12 08:36:32 +00:00
|
|
|
|
help='The state is set to \'Draft\', when a case is created.\
|
|
|
|
|
\nIf the case is in progress the state is set to \'Open\'.\
|
|
|
|
|
\nWhen the case is over, the state is set to \'Done\'.\
|
2010-05-14 09:29:24 +00:00
|
|
|
|
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
|
|
|
|
|
'company_id': fields.many2one('res.company', 'Company'),
|
|
|
|
|
'user_id': fields.many2one('res.users', 'Responsible'),
|
2010-05-12 08:36:32 +00:00
|
|
|
|
# Applicant Columns
|
2010-02-28 20:36:51 +00:00
|
|
|
|
'date_closed': fields.datetime('Closed', readonly=True),
|
|
|
|
|
'date': fields.datetime('Date'),
|
|
|
|
|
'priority': fields.selection(AVAILABLE_PRIORITIES, 'Appreciation'),
|
|
|
|
|
'job_id': fields.many2one('hr.job', 'Applied Job'),
|
|
|
|
|
'salary_proposed': fields.float('Proposed Salary'),
|
|
|
|
|
'salary_expected': fields.float('Expected Salary'),
|
|
|
|
|
'availability': fields.integer('Availability (Days)'),
|
|
|
|
|
'partner_name': fields.char("Applicant's Name", size=64),
|
|
|
|
|
'partner_phone': fields.char('Phone', size=32),
|
|
|
|
|
'partner_mobile': fields.char('Mobile', size=32),
|
2010-05-14 09:29:24 +00:00
|
|
|
|
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'hr.applicant')]"),
|
|
|
|
|
'type_id': fields.many2one('crm.case.resource.type', 'Degree', domain="[('section_id','=',section_id),('object_id.model', '=', 'hr.applicant')]"),
|
|
|
|
|
'department_id':fields.many2one('hr.department', 'Department'),
|
2010-02-28 20:36:51 +00:00
|
|
|
|
'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
|
2010-03-02 12:48:29 +00:00
|
|
|
|
'survey' : fields.related('job_id', 'survey_id', type='many2one', relation='survey', string='Survey'),
|
|
|
|
|
'response' : fields.integer("Response"),
|
2010-02-28 20:36:51 +00:00
|
|
|
|
}
|
2010-04-07 14:40:28 +00:00
|
|
|
|
|
2010-05-10 12:59:15 +00:00
|
|
|
|
def onchange_job(self,cr, uid, ids, job, context={}):
|
|
|
|
|
result = {}
|
|
|
|
|
if job:
|
|
|
|
|
job_obj = self.pool.get('hr.job')
|
|
|
|
|
result['department_id'] = job_obj.browse(cr, uid, job).department_id.id
|
|
|
|
|
return {'value': result}
|
|
|
|
|
return {'value': {'department_id': []}}
|
|
|
|
|
|
2010-04-07 14:40:28 +00:00
|
|
|
|
def stage_previous(self, cr, uid, ids, context=None):
|
|
|
|
|
"""This function computes previous stage for case from its current stage
|
2010-04-23 07:24:58 +00:00
|
|
|
|
using available stage for that case type
|
2010-04-07 14:40:28 +00:00
|
|
|
|
@param self: The object pointer
|
|
|
|
|
@param cr: the current row, from the database cursor,
|
|
|
|
|
@param uid: the current user’s ID for security checks,
|
|
|
|
|
@param ids: List of case IDs
|
|
|
|
|
@param context: A standard dictionary for contextual values"""
|
|
|
|
|
if not context:
|
|
|
|
|
context = {}
|
|
|
|
|
for case in self.browse(cr, uid, ids, context):
|
|
|
|
|
section = (case.section_id.id or False)
|
|
|
|
|
st = case.stage_id.id or False
|
2010-05-11 13:54:14 +00:00
|
|
|
|
stage_ids = self.pool.get('hr.recruitment.stage').search(cr, uid, [])
|
2010-04-07 14:40:28 +00:00
|
|
|
|
if st and stage_ids.index(st):
|
|
|
|
|
self.write(cr, uid, [case.id], {'stage_id': stage_ids[stage_ids.index(st)-1]})
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def stage_next(self, cr, uid, ids, context=None):
|
|
|
|
|
"""This function computes next stage for case from its current stage
|
2010-04-23 07:24:58 +00:00
|
|
|
|
using available stage for that case type
|
2010-04-07 14:40:28 +00:00
|
|
|
|
@param self: The object pointer
|
|
|
|
|
@param cr: the current row, from the database cursor,
|
|
|
|
|
@param uid: the current user’s ID for security checks,
|
|
|
|
|
@param ids: List of case IDs
|
|
|
|
|
@param context: A standard dictionary for contextual values"""
|
|
|
|
|
if not context:
|
|
|
|
|
context = {}
|
|
|
|
|
for case in self.browse(cr, uid, ids, context):
|
|
|
|
|
section = (case.section_id.id or False)
|
|
|
|
|
st = case.stage_id.id or False
|
2010-05-11 13:54:14 +00:00
|
|
|
|
stage_ids = self.pool.get('hr.recruitment.stage').search(cr, uid, [])
|
2010-04-07 14:40:28 +00:00
|
|
|
|
if st and len(stage_ids) != stage_ids.index(st)+1:
|
|
|
|
|
self.write(cr, uid, [case.id], {'stage_id': stage_ids[stage_ids.index(st)+1]})
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def action_makeMeeting(self, cr, uid, ids, context=None):
|
|
|
|
|
"""
|
|
|
|
|
This opens Meeting's calendar view to schedule meeting on current Opportunity
|
|
|
|
|
@param self: The object pointer
|
|
|
|
|
@param cr: the current row, from the database cursor,
|
|
|
|
|
@param uid: the current user’s ID for security checks,
|
|
|
|
|
@param ids: List of Opportunity to Meeting IDs
|
|
|
|
|
@param context: A standard dictionary for contextual values
|
|
|
|
|
|
|
|
|
|
@return : Dictionary value for created Meeting view
|
|
|
|
|
"""
|
|
|
|
|
value = {}
|
|
|
|
|
for opp in self.browse(cr, uid, ids):
|
|
|
|
|
data_obj = self.pool.get('ir.model.data')
|
|
|
|
|
|
|
|
|
|
# Get meeting views
|
|
|
|
|
result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_meetings_filter')
|
|
|
|
|
res = data_obj.read(cr, uid, result, ['res_id'])
|
|
|
|
|
id1 = data_obj._get_id(cr, uid, 'crm', 'crm_case_calendar_view_meet')
|
|
|
|
|
id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_meet')
|
|
|
|
|
id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_meet')
|
|
|
|
|
if id1:
|
|
|
|
|
id1 = data_obj.browse(cr, uid, id1, context=context).res_id
|
|
|
|
|
if id2:
|
|
|
|
|
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
|
|
|
|
|
if id3:
|
|
|
|
|
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
|
|
|
|
|
|
|
|
|
|
context = {
|
|
|
|
|
'default_opportunity_id': opp.id,
|
|
|
|
|
'default_partner_id': opp.partner_id and opp.partner_id.id or False,
|
|
|
|
|
'default_section_id': opp.section_id and opp.section_id.id or False,
|
|
|
|
|
'default_email_from': opp.email_from,
|
|
|
|
|
'default_state': 'open',
|
|
|
|
|
'default_name': opp.name
|
|
|
|
|
}
|
|
|
|
|
value = {
|
2010-04-29 10:54:25 +00:00
|
|
|
|
'name': ('Meetings'),
|
2010-04-07 14:40:28 +00:00
|
|
|
|
'domain': "[('user_id','=',%s)]" % (uid),
|
|
|
|
|
'context': context,
|
|
|
|
|
'view_type': 'form',
|
|
|
|
|
'view_mode': 'calendar,form,tree',
|
|
|
|
|
'res_model': 'crm.meeting',
|
|
|
|
|
'view_id': False,
|
|
|
|
|
'views': [(id1, 'calendar'), (id2, 'form'), (id3, 'tree')],
|
|
|
|
|
'type': 'ir.actions.act_window',
|
|
|
|
|
'search_view_id': res['res_id'],
|
|
|
|
|
'nodestroy': True
|
|
|
|
|
}
|
|
|
|
|
return value
|
|
|
|
|
|
2010-04-07 13:46:01 +00:00
|
|
|
|
def action_print_survey(self, cr, uid, ids, context=None):
|
|
|
|
|
"""
|
|
|
|
|
If response is available then print this response otherwise print survey form(print template of the survey).
|
|
|
|
|
|
|
|
|
|
@param self: The object pointer
|
|
|
|
|
@param cr: the current row, from the database cursor,
|
|
|
|
|
@param uid: the current user’s ID for security checks,
|
|
|
|
|
@param ids: List of Survey IDs
|
|
|
|
|
@param context: A standard dictionary for contextual values
|
|
|
|
|
@return : Dictionary value for print survey form.
|
|
|
|
|
"""
|
|
|
|
|
if not context:
|
|
|
|
|
context = {}
|
2010-04-08 05:25:40 +00:00
|
|
|
|
record = self.browse(cr, uid, ids, context)
|
|
|
|
|
record = record and record[0]
|
2010-05-12 08:36:32 +00:00
|
|
|
|
context.update({'survey_id': record.survey.id, 'response_id' : [record.response], 'response_no':0, })
|
2010-04-09 11:22:38 +00:00
|
|
|
|
value = self.pool.get("survey").action_print_survey(cr, uid, ids, context)
|
|
|
|
|
return value
|
2010-02-28 20:36:51 +00:00
|
|
|
|
hr_applicant()
|
2010-03-02 12:48:29 +00:00
|
|
|
|
|
|
|
|
|
class hr_job(osv.osv):
|
|
|
|
|
_inherit = "hr.job"
|
|
|
|
|
_name = "hr.job"
|
|
|
|
|
_columns = {
|
|
|
|
|
'survey_id': fields.many2one('survey', 'Survey'),
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-11 13:54:14 +00:00
|
|
|
|
hr_job()
|
|
|
|
|
|
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|