[IMP] improved code, remove unneccesary changes and convert application_count function field to one2many field.
bzr revid: tpa@tinyerp.com-20131224072224-b7gq9z4mqhyh7540
This commit is contained in:
+2
-2
@@ -144,13 +144,13 @@ class hr_job(osv.osv):
|
||||
def action_employee_to_hire(self, cr, uid, id, value, context=None):
|
||||
return self.write(cr, uid, [id], {'no_of_recruitment': value}, context=context)
|
||||
|
||||
def job_recruitment(self, cr, uid, ids, *args):
|
||||
def job_recruitment(self, cr, uid, ids, context=None):
|
||||
for job in self.browse(cr, uid, ids):
|
||||
no_of_recruitment = job.no_of_recruitment == 0 and 1 or job.no_of_recruitment
|
||||
self.write(cr, uid, [job.id], {'state': 'recruit', 'no_of_recruitment': no_of_recruitment})
|
||||
return True
|
||||
|
||||
def job_open(self, cr, uid, ids, *args):
|
||||
def job_open(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {'state': 'open', 'no_of_recruitment': 0,'no_of_hired_employee': 0})
|
||||
return True
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ msgstr ""
|
||||
|
||||
#. module: hr
|
||||
#: view:hr.job:0
|
||||
msgid "Launch Recruitment"
|
||||
msgid "Launch Recruitement"
|
||||
msgstr ""
|
||||
|
||||
#. module: hr
|
||||
@@ -690,7 +690,7 @@ msgstr ""
|
||||
|
||||
#. module: hr
|
||||
#: selection:hr.job,state:0
|
||||
msgid "Recruitment in Progress"
|
||||
msgid "Recruitement in Progress"
|
||||
msgstr ""
|
||||
|
||||
#. module: hr
|
||||
|
||||
@@ -244,7 +244,8 @@ class hr_applicant(osv.Model):
|
||||
if context is None:
|
||||
context = {}
|
||||
res = super(hr_applicant, self).default_get(cr, uid, fields, context=context)
|
||||
if context.get('active_id'):
|
||||
#NOTE:to set default user_id in applicant if applicant directly created from kanban action of job because currently web is not parsing value in context on action.
|
||||
if context.get('active_model') == "hr.job" and context.get('active_id'):
|
||||
job = self.pool.get('hr.job').browse(cr, uid, context.get('active_id'), context=context)
|
||||
res.update({'user_id': job.user_id.id})
|
||||
return res
|
||||
@@ -503,17 +504,8 @@ class hr_job(osv.osv):
|
||||
_name = "hr.job"
|
||||
_inherits = {'mail.alias': 'alias_id'}
|
||||
|
||||
def _application_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||
"""Calculate total Applications per job"""
|
||||
res = dict.fromkeys(ids, 0)
|
||||
applicant_obj = self.pool.get('hr.applicant')
|
||||
applicant_ids = applicant_obj.search(cr, uid, [('job_id', 'in', ids)], context=context)
|
||||
for applicant in applicant_obj.browse(cr, uid, applicant_ids, context=context):
|
||||
res[applicant.job_id.id] += 1
|
||||
return res
|
||||
|
||||
def _get_attached_docs(self, cr, uid, ids, field_name, arg, context=None):
|
||||
"""Calculate total attached CV per job"""
|
||||
"""Calculate total attached CV to applications and documents per job"""
|
||||
res = {}
|
||||
attachment_obj = self.pool.get('ir.attachment')
|
||||
for job_id in ids:
|
||||
@@ -526,7 +518,7 @@ class hr_job(osv.osv):
|
||||
'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True,
|
||||
help="Email alias for this job position. New emails will automatically "
|
||||
"create new applicants for this job position."),
|
||||
'application_count': fields.function(_application_count, type='integer', string="Total Applications"),
|
||||
'application_ids': fields.one2many('hr.applicant', 'job_id', 'Applications'),
|
||||
'manager_id': fields.related('department_id', 'manager_id', type='many2one', string='Department Manager', relation='hr.employee', readonly=True, store=True),
|
||||
'doc_count':fields.function(_get_attached_docs, string="Number of documents attached", type='int'),
|
||||
'user_id': fields.many2one('res.users', 'Recruitment Responsible', track_visibility='onchange'),
|
||||
|
||||
@@ -379,11 +379,10 @@
|
||||
<field name="department_id"/>
|
||||
<field name="no_of_recruitment"/>
|
||||
<field name="color"/>
|
||||
<field name="application_count"/>
|
||||
<field name="application_ids"/>
|
||||
<field name="no_of_hired_employee"/>
|
||||
<field name="manager_id"/>
|
||||
<field name="survey_id"/>
|
||||
<field name="message_summary"/>
|
||||
<field name="state"/>
|
||||
<field name="user_id"/>
|
||||
<templates>
|
||||
@@ -426,8 +425,8 @@
|
||||
<t t-if="record.state.raw_value == 'recruit'">
|
||||
<div class="oe_applications">
|
||||
<a name="%(action_hr_job_applications)d" type="action">
|
||||
<span t-if="record.application_count.value gt 1"><field name="application_count"/> Applications</span>
|
||||
<span t-if="record.application_count.value lt 2"><field name="application_count"/> Application</span>
|
||||
<span t-if="record.application_ids.raw_value.length gt 1"><t t-esc="record.application_ids.raw_value.length"/> Applications</span>
|
||||
<span t-if="record.application_ids.raw_value.length lt 2"><t t-esc="record.application_ids.raw_value.length"/> Application</span>
|
||||
</a>
|
||||
<br/>
|
||||
<a t-if="record.doc_count.raw_value" name="attachment_tree_view" type="object">
|
||||
|
||||
@@ -37,6 +37,10 @@ class hr_applicant_settings(osv.osv_memory):
|
||||
'alias_domain' : fields.char('Alias Domain'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'alias_domain': lambda self, cr, uid, context:self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context),
|
||||
}
|
||||
|
||||
def get_default_alias_prefix(self, cr, uid, ids, context=None):
|
||||
alias_name = ''
|
||||
mail_alias = self.pool.get('mail.alias')
|
||||
@@ -66,13 +70,3 @@ class hr_applicant_settings(osv.osv_memory):
|
||||
else:
|
||||
mail_alias.create_unique_alias(cr, uid, {'alias_name': record.alias_prefix}, model_name="hr.applicant", context=context)
|
||||
return True
|
||||
|
||||
def get_default_alias_domain(self, cr, uid, ids, context=None):
|
||||
alias_domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context)
|
||||
if not alias_domain:
|
||||
domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "web.base.url", context=context)
|
||||
try:
|
||||
alias_domain = urlparse.urlsplit(domain).netloc.split(':')[0]
|
||||
except Exception:
|
||||
pass
|
||||
return {'alias_domain': alias_domain}
|
||||
|
||||
@@ -10,5 +10,4 @@ openerp.hr_recruitment = function (openerp) {
|
||||
},
|
||||
});
|
||||
|
||||
openerp.web_kanban.fields_registry.add("justgage", "openerp.hr_recruitment.GaugeWidget");
|
||||
}
|
||||
Reference in New Issue
Block a user