[FIX,IMP]: hr_recruitment: Fixed views, objects and reports accroding to changes in crm and crm reports
bzr revid: rpa@tinyerp.com-20100512083632-a6mkwyrl3s58yklo
This commit is contained in:
parent
e21a8d4fda
commit
28f47fa998
|
@ -19,47 +19,75 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields,osv,orm
|
||||
from osv import fields, osv
|
||||
from crm import crm
|
||||
|
||||
AVAILABLE_STATES = [
|
||||
('draft','New'),
|
||||
('open','In Progress'),
|
||||
('cancel', 'Refused'),
|
||||
('done', 'Hired'),
|
||||
('pending','Pending')
|
||||
('draft', 'New'),
|
||||
('open', 'In Progress'),
|
||||
('cancel', 'Refused'),
|
||||
('done', 'Hired'),
|
||||
('pending', 'Pending')
|
||||
]
|
||||
|
||||
AVAILABLE_PRIORITIES = [
|
||||
('5','Not Good'),
|
||||
('4','On Average'),
|
||||
('3','Good'),
|
||||
('2','Very Good'),
|
||||
('1','Excellent')
|
||||
('5', 'Not Good'),
|
||||
('4', 'On Average'),
|
||||
('3', 'Good'),
|
||||
('2', 'Very Good'),
|
||||
('1', 'Excellent')
|
||||
]
|
||||
|
||||
|
||||
class hr_applicant(osv.osv):
|
||||
class hr_applicant(osv.osv, crm.crm_case):
|
||||
_name = "hr.applicant"
|
||||
_description = "Applicant Cases"
|
||||
_order = "id desc"
|
||||
_inherit ='crm.case'
|
||||
_inherit ='mailgate.thread'
|
||||
|
||||
_columns = {
|
||||
'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),
|
||||
'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'),
|
||||
'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
|
||||
'survey' : fields.related('job_id', 'survey_id', type='many2one', relation='survey', string='Survey'),
|
||||
'response' : fields.integer("Response"),
|
||||
'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'),
|
||||
'section_id': fields.many2one('crm.case.section', 'Sales Team', \
|
||||
select=True, help='Sales team to which Case belongs to.\
|
||||
Define Responsible user and Email account for mail gateway.'),
|
||||
'email_from': fields.char('Email', size=128, help="These people will receive email."),
|
||||
'email_cc': fields.text('Watchers Emails', size=252 , help="These people\
|
||||
will receive a copy of the future" \
|
||||
" communication between partner and users by email"),
|
||||
'probability': fields.float('Probability'),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \
|
||||
domain="[('partner_id','=',partner_id)]"),
|
||||
'create_date': fields.datetime('Creation Date' , readonly=True),
|
||||
'write_date': fields.datetime('Update Date' , readonly=True),
|
||||
'stage_id': fields.many2one ('crm.case.stage', 'Stage', \
|
||||
domain="[('section_id','=',section_id),\
|
||||
('object_id.model', '=', 'crm.opportunity')]"),
|
||||
'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True,
|
||||
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\'.\
|
||||
\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'),
|
||||
# Applicant Columns
|
||||
'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),
|
||||
'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'),
|
||||
'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
|
||||
'survey' : fields.related('job_id', 'survey_id', type='many2one', relation='survey', string='Survey'),
|
||||
'response' : fields.integer("Response"),
|
||||
}
|
||||
|
||||
def stage_previous(self, cr, uid, ids, context=None):
|
||||
|
@ -127,24 +155,24 @@ class hr_applicant(osv.osv):
|
|||
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_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 = {
|
||||
'name': ('Meetings'),
|
||||
'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'],
|
||||
'name': ('Meetings'),
|
||||
'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
|
||||
|
@ -164,7 +192,7 @@ class hr_applicant(osv.osv):
|
|||
context = {}
|
||||
record = self.browse(cr, uid, ids, context)
|
||||
record = record and record[0]
|
||||
context.update({'survey_id': record.survey.id, 'response_id' : [record.response], 'response_no':0,})
|
||||
context.update({'survey_id': record.survey.id, 'response_id' : [record.response], 'response_no':0, })
|
||||
value = self.pool.get("survey").action_print_survey(cr, uid, ids, context)
|
||||
return value
|
||||
hr_applicant()
|
||||
|
@ -173,7 +201,7 @@ class hr_job(osv.osv):
|
|||
_inherit = "hr.job"
|
||||
_name = "hr.job"
|
||||
_columns = {
|
||||
'survey_id': fields.many2one('survey', 'Survey'),
|
||||
'survey_id': fields.many2one('survey', 'Survey'),
|
||||
}
|
||||
|
||||
hr_job()
|
|
@ -71,7 +71,7 @@
|
|||
<group colspan="4" col="8">
|
||||
<field name="name" string="Subject"/>
|
||||
<label string="Stage: " align="1.0"/>
|
||||
<group colspan="1" col="2">
|
||||
<group colspan="1" col="3">
|
||||
<field name="stage_id" nolabel="1"/>
|
||||
<button name="stage_previous" string="" type="object" icon="gtk-go-back"/>
|
||||
<button icon="gtk-go-forward" string="" name="stage_next" type="object"/>
|
||||
|
@ -134,19 +134,24 @@
|
|||
<field name="id"/>
|
||||
<field name="active"/>
|
||||
<field name="log_ids" nolabel="1" colspan="4">
|
||||
<form string="Actions">
|
||||
<separator string="Action Information" colspan="4"/>
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="date"/>
|
||||
<field name="user_id"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
<tree string="Logs">
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="date"/>
|
||||
<field name="user_id"/>
|
||||
</tree>
|
||||
<form string="Logs">
|
||||
<separator string="Action Information" colspan="4"/>
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="date"/>
|
||||
<field name="user_id"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Emails" groups="base.group_extended">
|
||||
<group colspan="4">
|
||||
<field colspan="4" name="email_cc" string="CC"/>
|
||||
</group>
|
||||
<field name="history_line" colspan="4" nolabel="1" mode="form,tree">
|
||||
<field name="message_ids" colspan="4" nolabel="1" mode="form,tree">
|
||||
<form string="Communication history">
|
||||
<group col="6" colspan="4">
|
||||
<field name="date"/>
|
||||
|
@ -228,7 +233,7 @@
|
|||
help="My Department"/>
|
||||
</field>
|
||||
<newline/>
|
||||
<group expand="1" string="Group By..." colspan="11" col="20">
|
||||
<group expand="0" string="Group By..." colspan="11" col="20">
|
||||
<filter string="Department" icon="terp-project" domain="[]" context="{'group_by':'department_id'}"/>
|
||||
<filter string="Responsible" icon="terp-project" domain="[]" context="{'group_by':'user_id'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
|
|
|
@ -23,13 +23,74 @@ import tools
|
|||
from osv import fields,osv
|
||||
from hr_recruitment import hr_recruitment
|
||||
|
||||
AVAILABLE_STATES = [
|
||||
('draft','Draft'),
|
||||
('open','Open'),
|
||||
('cancel', 'Cancelled'),
|
||||
('done', 'Closed'),
|
||||
('pending','Pending')
|
||||
]
|
||||
|
||||
class hr_recruitment_report(osv.osv):
|
||||
_name = "hr.recruitment.report"
|
||||
_description = "Recruitments Statistics"
|
||||
_inherit = "crm.case.report"
|
||||
_auto = False
|
||||
_rec_name = 'date'
|
||||
|
||||
def _get_data(self, cr, uid, ids, field_name, arg, context={}):
|
||||
|
||||
""" @param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of case and section Data’s IDs
|
||||
@param context: A standard dictionary for contextual values """
|
||||
|
||||
res = {}
|
||||
state_perc = 0.0
|
||||
avg_ans = 0.0
|
||||
|
||||
for case in self.browse(cr, uid, ids, context):
|
||||
if field_name != 'avg_answers':
|
||||
state = field_name[5:]
|
||||
cr.execute("select count(*) from crm_opportunity where \
|
||||
section_id =%s and state='%s'"%(case.section_id.id, state))
|
||||
state_cases = cr.fetchone()[0]
|
||||
perc_state = (state_cases / float(case.nbr)) * 100
|
||||
|
||||
res[case.id] = perc_state
|
||||
else:
|
||||
model_name = self._name.split('report.')
|
||||
if len(model_name) < 2:
|
||||
res[case.id] = 0.0
|
||||
else:
|
||||
model_name = model_name[1]
|
||||
|
||||
cr.execute("select count(*) from crm_case_log l, ir_model m \
|
||||
where l.model_id=m.id and m.model = '%s'" , model_name)
|
||||
logs = cr.fetchone()[0]
|
||||
|
||||
avg_ans = logs / case.nbr
|
||||
res[case.id] = avg_ans
|
||||
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Year', size=64, required=False, readonly=True),
|
||||
'user_id':fields.many2one('res.users', 'User', readonly=True),
|
||||
'section_id':fields.many2one('crm.case.section', 'Section', readonly=True),
|
||||
'nbr': fields.integer('# of Cases', readonly=True),
|
||||
'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
|
||||
'avg_answers': fields.function(_get_data, string='Avg. Answers', method=True, type="integer"),
|
||||
'perc_done': fields.function(_get_data, string='%Done', method=True, type="float"),
|
||||
'perc_cancel': fields.function(_get_data, string='%Cancel', method=True, type="float"),
|
||||
'month':fields.selection([('01', 'January'), ('02', 'February'), \
|
||||
('03', 'March'), ('04', 'April'),\
|
||||
('05', 'May'), ('06', 'June'), \
|
||||
('07', 'July'), ('08', 'August'),\
|
||||
('09', 'September'), ('10', 'October'),\
|
||||
('11', 'November'), ('12', 'December')], 'Month', readonly=True),
|
||||
'company_id': fields.many2one('res.company', 'Company', readonly=True),
|
||||
'create_date': fields.datetime('Create Date', readonly=True),
|
||||
'day': fields.char('Day', size=128, readonly=True),
|
||||
'year': fields.char('Year', size=4, readonly=True),
|
||||
'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'),
|
||||
('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'),
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
</field>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Extended options..." colspan="10" col="12">
|
||||
<group expand="1" string="Extended options..." colspan="10" col="12">
|
||||
<filter icon="terp-hr"
|
||||
string="Hired"
|
||||
name="done"
|
||||
|
|
Loading…
Reference in New Issue