diff --git a/addons/hr_recruitment/__openerp__.py b/addons/hr_recruitment/__openerp__.py index 0de2eb5c94e..f9ae722c438 100644 --- a/addons/hr_recruitment/__openerp__.py +++ b/addons/hr_recruitment/__openerp__.py @@ -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', ], diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml index a74707e9ca0..d896d522d97 100644 --- a/addons/hr_recruitment/hr_recruitment_view.xml +++ b/addons/hr_recruitment/hr_recruitment_view.xml @@ -267,6 +267,7 @@ +
    @@ -311,6 +312,13 @@ +
    diff --git a/addons/hr_recruitment/static/src/js/hr_recruitment.js b/addons/hr_recruitment/static/src/js/hr_recruitment.js new file mode 100644 index 00000000000..5a2d6bd92b4 --- /dev/null +++ b/addons/hr_recruitment/static/src/js/hr_recruitment.js @@ -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(); + } + } + }); +};