[IMP] hr_recruitment: add the tags to the kanban view

bzr revid: abo@openerp.com-20120816151148-ymqe4mreppwk72lh
This commit is contained in:
Antonin Bourguignon 2012-08-16 17:11:48 +02:00
parent 89a27bf5b6
commit 18e8d506e7
3 changed files with 45 additions and 1 deletions

View File

@ -57,13 +57,14 @@ system to store and search in your CV base.
'board_hr_recruitment_statistical_view.xml',
'hr_recruitment_installer_view.xml',
'res_config_view.xml',
],
],
'init_xml': [
'hr_recruitment_data.xml'
],
'demo_xml': [
'hr_recruitment_demo.yml',
],
'js': ['static/src/js/hr_recruitment.js'],
'test':[
'test/recruitment_process.yml',
],

View File

@ -267,6 +267,7 @@
<field name="job_id"/>
<field name="title_action"/>
<field name="department_id"/>
<field name="categ_ids"/>
<templates>
<t t-name="kanban-tooltip">
<ul class="oe_kanban_tooltip">
@ -311,6 +312,13 @@
<img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" width="24" height="24" class="oe_kanban_avatar"/>
</div>
<div class="oe_kanban_footer_left" style="margin-top:5px;">
<div class="oe_left oe_tags">
<t t-foreach="record.categ_ids.raw_value" t-as="categ_id">
<span class="oe_tag" t-att-data-categ_id="categ_id"></span>
</t>
</div>
</div>
</div>
<div class="oe_clear"></div>
</div>

View File

@ -0,0 +1,35 @@
openerp.hr_recruitment = function(openerp) {
openerp.web_kanban.KanbanView.include({
applicant_display_categ_names: function() {
/*
* Set proper names to applicant categories.
* In kanban views, many2many fields only return a list of ids.
* Therefore, we have to fetch the matching data by ourselves.
*/
var self = this;
var categ_ids = [];
// Collect categories ids
self.$element.find('span[data-categ_id]').each(function() {
categ_ids.push($(this).data('categ_id'));
});
// Find their matching names
var dataset = new openerp.web.DataSetSearch(self, 'hr.applicant_category', self.session.context, [['id', 'in', _.uniq(categ_ids)]]);
dataset.read_slice(['id', 'name']).then(function(result) {
_.each(result, function(v, k) {
// Set the proper value in the DOM and display the element
self.$element.find('span[data-categ_id=' + v.id + ']').text(v.name);
});
});
},
on_groups_started: function() {
var self = this;
self._super.apply(self, arguments);
if (self.dataset.model === 'hr.applicant') {
self.applicant_display_categ_names();
}
}
});
};