Skip to content
Permalink
Browse files

[IMP]hr_recruitment:Redesigned hr_job kanban view cards, created Link…

…din default source for jobs, improved applicant tree view, remove left panel from kanban view , made some fixes to email template of recruitement
  • Loading branch information
lextjes committed Mar 16, 2020
1 parent 34f62ae commit a0f5333d48f4b35d47cc0d1cc94fff6e2655e758
@@ -116,7 +116,7 @@

<hr width="97%" style="background-color: rgb(204,204,204); border: medium none; clear: both; display: block; font-size: 0px; min-height: 1px; line-height: 0; margin: 16px 0px 16px 0px;"/>
<h3 style="color:#9A6C8E;"><strong>What is the next step?</strong></h3>
We usually <strong>answer applications within 3 days</strong>.
We usually <strong>answer applications within a few days</strong>.
<br/><br/>
The next step is either a call or a meeting in our offices.
<br/>
@@ -157,11 +157,6 @@
% endif
<br/>

% if object.job_id.address_id:
<a href="https://maps.google.com/maps?q=${location}" target="new">
<img src="http://maps.googleapis.com/maps/api/staticmap?autoscale=1&amp;size=598x200&amp;maptype=roadmap&amp;format=png&amp;visual_refresh=true&amp;markers=size:mid%7Ccolor:0xa5117d%7Clabel:%7C${location}" style="vertical-align:bottom;"/>
</a>
% endif
</div>
</td>
</tr>
@@ -214,7 +209,7 @@
% endif

<h3 style="color:#9A6C8E;"><strong>What is the next step?</strong></h3>
We usually <strong>answer applications within 3 days.</strong><br/><br/>
We usually <strong>answer applications within a few days.</strong><br/><br/>
Feel free to <strong>contact us if you want a faster
feedback</strong> or if you don't get news from us
quickly enough (just reply to this email).
@@ -362,7 +357,6 @@
</record>
<record model="hr.recruitment.stage" id="stage_job2">
<field name="name">First Interview</field>
<field name="template_id" ref="email_template_data_applicant_interest"/>
<field name="sequence">2</field>
</record>
<record model="hr.recruitment.stage" id="stage_job3">
@@ -1,7 +1,15 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

import json
from datetime import datetime, timedelta
from babel.dates import format_datetime, format_date
from odoo import api, fields, models, _

from odoo.osv import expression
from odoo.release import version
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT as DF
from odoo.tools.misc import formatLang, format_date as odoo_format_date, get_lang
import random
import ast

class Job(models.Model):
_name = "hr.job"
@@ -36,7 +44,7 @@ def _get_default_favorite_user_ids(self):
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.")
color = fields.Integer("Color Index")
color = fields.Integer("Color Index",default=0)
is_favorite = fields.Boolean(compute='_compute_is_favorite', inverse='_inverse_is_favorite')
favorite_user_ids = fields.Many2many('res.users', 'job_favorite_user_rel', 'job_id', 'user_id', default=_get_default_favorite_user_ids)

@@ -78,6 +86,23 @@ def _compute_application_count(self):
for job in self:
job.application_count = result.get(job.id, 0)

def action_view_job(self):
return {
'name': _('Job Position'),
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'hr.job',
'res_id': self.id,
}
def action_hr_job_sources_func(self):
return{
'name':_('Job Position'),
'type':'ir.actions.act_window',
'res_model':'hr.recruitment.source',
'view_mode':'tree',
'domain':'[("job_id","=",active_id)]',
'context':'{"default_job_id": active_id,"default_source_id":6}',
}
def _get_first_stage(self):
self.ensure_one()
return self.env['hr.recruitment.stage'].search([
@@ -106,7 +131,12 @@ def get_alias_values(self):
@api.model
def create(self, vals):
vals['favorite_user_ids'] = vals.get('favorite_user_ids', []) + [(4, self.env.uid)]
return super(Job, self).create(vals)
res = super(Job, self).create(vals)
new_source = self.env['hr.recruitment.source'].create({
'source_id': 6,
'job_id': res.id
})
return res

def _creation_subtype(self):
return self.env.ref('hr_recruitment.mt_job_new')
@@ -134,3 +164,31 @@ def edit_dialog(self):
'type': 'ir.actions.act_window',
'target': 'inline'
}
kanban_dashboard_graph = fields.Text(compute='_kanban_dashboard_graph')
def _kanban_dashboard_graph(self):
for job in self:
job.kanban_dashboard_graph = json.dumps(job.get_line_graph_datas())

def get_line_graph_datas(self):

locale = get_lang(self.env).code
def build_graph_data(date, amount):
#display date in locale format
name = format_date(date, 'd LLLL Y', locale=locale)
short_name = format_date(date, 'd MMM', locale=locale)
return {'x':short_name,'y': amount, 'name':name}

self.ensure_one()
today = datetime.today()
Applications = self.env['hr.applicant']
data = []
is_sample_data=False
color='#875A7B'
for i in range(7, 0,-1):
current_date_upperbound = today + timedelta(days=-i)#Use of upper and lowerbound to get Applicant with date_open equal to lowerbound date who looks like YYYY-MM-DD after strftime by testing between upper and lowerbound we get them all even if date_open is in datetime format with hours and minutes
current_date_lowerbound = today + timedelta(days=-(i+1))
amount_applications = Applications.search([('job_id', '=',self.id),'&',('date_open','>',current_date_lowerbound.strftime(DF)),('date_open','<=',current_date_upperbound.strftime(DF))])
data_item = build_graph_data(current_date_upperbound, len(amount_applications))
data.append(data_item)

return [{'values': data, 'title': '', 'key': 'Applications Count', 'area': True, 'color': color, 'is_sample_data': is_sample_data}]
@@ -3,7 +3,7 @@
&.o_kanban_ungrouped .o_kanban_record {
width: 350px;
&:not(.o_kanban_ghost) {
height: 180px;
height: 250px;
}
}

@@ -95,3 +95,17 @@
text-align: right;
}
}

.width_class[data-id="source_id"] {
width:25%;
}

.width_class[data-id="email"] {
width:25%;
}
.width_class[data-id="create_alias"] {
width:25%;
}
.width_class[data-id="url"] {
width:25%;
}
@@ -24,6 +24,7 @@
<field name="manager_id"/>
<field name="state"/>
<field name="user_id"/>
<field name="hr_responsible_id"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="#{!selection_mode ? kanban_color(record.color.raw_value) : ''}">
@@ -32,7 +33,7 @@
<div class="o_primary col-12">
<span><t t-esc="record.name.value"/></span>
</div>
<div class="o_kanban_record_subtitle col-12 text-muted">
<div class="o_kanban_record_subtitle text-muted">
<field name="user_id" />
</div>
<field name="is_favorite" widget="boolean_favorite" nolabel="1"/>
@@ -44,7 +45,7 @@
<a class="o_kanban_manage_toggle_button" href="#"><i class="fa fa-ellipsis-v" role="img" aria-label="Manage" title="Manage"/></a>
</div>
</div>
<div class="container o_kanban_card_content">
<div t-att-class="'container o_kanban_card_content o-sample_data'">
<t t-if="record.state.raw_value == 'recruit'">
<div class="row">
<div class="col-6">
@@ -54,7 +55,7 @@
</div>
<div class="col-6">
<field name="new_application_count"/> New Applications <br/>
<field name="no_of_recruitment"/> To Recruit
<a type="object" name="action_view_job"><field name="no_of_recruitment"/> To Recruit</a>
</div>
</div>
</t>
@@ -64,12 +65,13 @@
<button class="btn btn-secondary" name="set_recruit" type="object">Start Recruitment</button>
</div>
</div>
<t t-call="JournalBodyGraph"/>
</t>
<div name="kanban_boxes" class="row o_recruitment_kanban_boxes">
<div class="o_recruitment_kanban_box o_kanban_primary_bottom bottom_block" style="padding-left:8px;">
<div class="col-6"></div>
<div class="col-6">
<a type="action" name="%(action_hr_job_sources)d">Share Trackers</a>
<a type="object" name="%(action_hr_job_sources_func)d">Link Trackers</a>
</div>
</div>
</div>
@@ -89,6 +91,9 @@
</div>
</div>
</t>
<t t-name="JournalBodyGraph">
<field name="kanban_dashboard_graph" t-att-graph_type="'line'" widget="dashboard_graph"/>
</t>
</templates>
</kanban>
</field>
@@ -102,12 +107,6 @@
<xpath expr="//field[@name='department_id']" position="after">
<filter string="My Job Positions" name="my_positions" domain="[('user_id', '=', uid)]"/>
</xpath>
<xpath expr="//group" position="after">
<searchpanel>
<field name="company_id" groups="base.group_multi_company" icon="fa-building"/>
<field name="user_id" icon="fa-users"/>
</searchpanel>
</xpath>
</field>
</record>

@@ -20,9 +20,33 @@
</record>

<!-- Applicants -->
<record id="hr_applicant_list_view" model="ir.ui.view">
<field name="name">Applications List</field>
<field name="model">hr.applicant</field>
<field eval="2" name="priority"/>
<field name="arch" type="xml">
<tree>
<field name="name" readonly="1"/>
<field name="partner_name"/>
<field name="job_id"/>
<field name="stage_id"/>
<field name="create_date" readonly="1" optional="show"/>
<field name="priority" optional="show"/>
<field name="salary_expected" optional="show"/>
<field name="availability" optional="show"/>
<field name="salary_proposed" optional="hidden"/>
<field name="email_from" readonly="1" optional="hidden"/>
<field name="partner_phone" readonly="1" optional="hidden"/>
<field name="medium_id" optional="hidden"/>
<field name="source_id" readonly="1" optional="hidden"/>
<field name="user_id" optional="hidden"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="crm_case_tree_view_job">
<field name="name">Applicants</field>
<field name="model">hr.applicant</field>
<field eval="3" name="priority"/>
<field name="arch" type="xml">
<tree string="Applicants" decoration-bf="message_needaction==True" multi_edit="1">
<field name="message_needaction" invisible="1"/>
@@ -96,6 +120,7 @@
<field name="legend_blocked" invisible="1"/>
<field name="legend_done" invisible="1"/>
<div class="oe_title">
<span class="o_form_label"><field name="name" readonly="1" nolabel="1"/></span>
<label for="name" class="oe_edit_only"/>
<h1><field name="name"/></h1>
<h2 class="o_row">
@@ -200,7 +225,7 @@
<separator/>
<filter string="Unread Messages" name="message_needaction" domain="[('message_needaction', '=', True)]"/>
<separator/>
<filter string="Archived" name="inactive" domain="[('active', '=', False)]"/>
<filter string="Archived/Refused" name="inactive" domain="[('active', '=', False)]"/>
<separator/>
<filter invisible="1" string="Late Activities" name="activities_overdue"
domain="[('activity_ids.date_deadline', '&lt;', context_today().strftime('%Y-%m-%d'))]"
@@ -386,7 +411,7 @@
<field name="res_model">hr.recruitment.source</field>
<field name="view_mode">tree</field>
<field name="domain">[('job_id', '=', active_id)]</field>
<field name="context">{'default_job_id': active_id}</field>
<field name="context">{'default_job_id': active_id,'default_source_id':3}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create some aliases to track where applicants come from
@@ -856,7 +881,7 @@ action = act
<field name="name">hr.recruitment.source.tree</field>
<field name="model">hr.recruitment.source</field>
<field name="arch" type="xml">
<tree string="Sources of Applicants" editable="top" class="o_recruitment_list">
<tree string="Sources of Applicants" editable="top" class="o_recruitment_list width_class">
<field name="source_id"/>
<button name="create_alias" string="Generate email alias" type="object" icon="fa-repeat text-success" />
<field name="email"/>
@@ -34,6 +34,9 @@
<record model="utm.source" id="utm_source_twitter">
<field name="name">Twitter</field>
</record>
<record model="utm.source" id="utm_source_linkedin">
<field name="name">LinkedIn</field>
</record>

<!-- UTM Medium -->
<record model="utm.medium" id="utm_medium_website">

0 comments on commit a0f5333

Please sign in to comment.
You can’t perform that action at this time.