Skip to content

Commit

Permalink
[IMP] hr_recruitment: Add kanban state to recruitment pipeline
Browse files Browse the repository at this point in the history
Purpose
=======

recruitment pipeline lacks a kanban state management

Specifications
==============

Add kanban state management like what is already done in project:
- A kanban state was added to the recruitment pipeline. The kanban colored dot is visible in the kanban view and in the form view.
- A search filter on the kanban state was also added.

Project : RD for Dummies
Task : 1819164
  • Loading branch information
mao-odoo authored and tivisse committed Jun 8, 2018
1 parent e1f2e72 commit d6d3081
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
17 changes: 17 additions & 0 deletions addons/hr_recruitment/models/hr_recruitment.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ class RecruitmentStage(models.Model):
fold = fields.Boolean(
"Folded in Recruitment Pipe",
help="This stage is folded in the kanban view when there are no records in that stage to display.")
legend_blocked = fields.Char(
'Red Kanban Label', default=lambda self: _('Blocked'), translate=True, required=True)
legend_done = fields.Char(
'Green Kanban Label', default=lambda self: _('Ready for Next Stage'), translate=True, required=True)
legend_normal = fields.Char(
'Grey Kanban Label', default=lambda self: _('In Progress'), translate=True, required=True)

@api.model
def default_get(self, fields):
Expand Down Expand Up @@ -156,6 +162,15 @@ def _default_company_id(self):
attachment_number = fields.Integer(compute='_get_attachment_number', string="Number of Attachments")
employee_name = fields.Char(related='emp_id.name', string="Employee Name")
attachment_ids = fields.One2many('ir.attachment', 'res_id', domain=[('res_model', '=', 'hr.applicant')], string='Attachments')
kanban_state = fields.Selection([
('normal', 'Grey'),
('done', 'Green'),
('blocked', 'Red')], string='Kanban State',
copy=False, default='normal', required=True)
legend_blocked = fields.Char(related='stage_id.legend_blocked', string='Kanban Blocked')
legend_done = fields.Char(related='stage_id.legend_done', string='Kanban Valid')
legend_normal = fields.Char(related='stage_id.legend_normal', string='Kanban Ongoing')


@api.depends('date_open', 'date_closed')
@api.one
Expand Down Expand Up @@ -267,6 +282,8 @@ def write(self, vals):
if 'stage_id' in vals:
vals['date_last_stage_update'] = fields.Datetime.now()
vals.update(self._onchange_stage_id_internal(vals.get('stage_id'))['value'])
if 'kanban_state' not in vals:
vals['kanban_state'] = 'normal'
for applicant in self:
vals['last_stage_id'] = applicant.stage_id.id
res = super(Applicant, self).write(vals)
Expand Down
9 changes: 8 additions & 1 deletion addons/hr_recruitment/static/src/scss/hr_job.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,11 @@
}
}
}
}
}

.o_kanban_view .oe_kanban_card {
.o_kanban_state_with_padding {
padding-left:7%;
padding-bottom:5%;
}
}
26 changes: 26 additions & 0 deletions addons/hr_recruitment/views/hr_recruitment_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
options='{"terminology": "archive"}'/>
</button>
</div>
<field name="kanban_state" widget="kanban_state_selection"/>
<field name="legend_normal" invisible="1"/>
<field name="legend_blocked" invisible="1"/>
<field name="legend_done" invisible="1"/>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
<h1><field name="name"/></h1>
Expand Down Expand Up @@ -201,6 +205,10 @@
<field name="user_id"/>
<field name="stage_id" domain="[]"/>
<separator/>
<filter string="Ready for Next Stage" name="done" domain="[('kanban_state', '=', 'done')]"/>
<filter string="Blocked" name="blocked" domain="[('kanban_state', '=', 'blocked')]"/>
<filter string="In progress" name="in_progress" domain="[('kanban_state', '=', 'normal')]"/>
<separator/>
<filter string="My Activities" name="activities_my"
domain="[('activity_ids.user_id', '=', uid)]"/>
<separator/>
Expand Down Expand Up @@ -324,6 +332,12 @@
<t t-esc="record.attachment_number.raw_value"/>
</span>
</a>
<div class="o_kanban_state_with_padding">
<field name="kanban_state" widget="kanban_state_selection"/>
<field name="legend_normal" invisible="1"/>
<field name="legend_blocked" invisible="1"/>
<field name="legend_done" invisible="1"/>
</div>
<img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" width="30" height="30" class="oe_kanban_avatar"/>
</div>

Expand Down Expand Up @@ -708,6 +722,18 @@
<field name="template_id" domain= "[('model_id.model', '=', 'hr.applicant')]"/>
</group>
</group>
<group string="Tooltips">
<p class="text-muted" colspan="2">
You can define here the labels that will be displayed for the kanban state instead
of the default labels.
</p>
<label for="legend_normal" string=" " class="o_status"/>
<field name="legend_normal" nolabel="1"/>
<label for="legend_blocked" string=" " class="o_status o_status_red"/>
<field name="legend_blocked" nolabel="1"/>
<label for="legend_done" string=" " class="o_status o_status_green"/>
<field name="legend_done" nolabel="1"/>
</group>
<separator string="Requirements"/>
<field name="requirements"/>
</form>
Expand Down

0 comments on commit d6d3081

Please sign in to comment.