[IMP] properly display categories in portal's issues view
since the many2many_tags widget doesn't work in kanban views, this is achieved by a bit Javascript - cf. portal_project_issue.js bzr revid: abo@openerp.com-20120711164002-y37dn0mjufbgy7lz
This commit is contained in:
@@ -42,5 +42,8 @@ portal are installed.
|
||||
'css': [
|
||||
'static/src/css/portal_project_issue.css',
|
||||
],
|
||||
'js': [
|
||||
'static/src/js/portal_project_issue.js',
|
||||
],
|
||||
}
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -25,9 +25,10 @@
|
||||
</div>
|
||||
<div class="oe_kanban_footer_left">
|
||||
<div class="oe_left">
|
||||
<!-- <field name="categ_ids" widget="many2many_tags"/> -->
|
||||
<t t-raw="record.categ_ids.raw_value"/>
|
||||
</div>
|
||||
<t t-foreach="record.categ_ids.raw_value" t-as="categ_id">
|
||||
<span class="oe_form_field_many2manytags_box" t-att-data-categ_id="categ_id"></span>
|
||||
</t
|
||||
> </div>
|
||||
<div class="oe_right">
|
||||
Creation: <field name="create_date"/>
|
||||
<span class="oe_kanban_highlight">
|
||||
|
||||
@@ -30,3 +30,22 @@
|
||||
.oe_portal_project_issue .oe_fold_column.oe_kanban_record .oe_kanban_footer_left {
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
/* many2many tags */
|
||||
.oe_portal_project_issue * span.oe_form_field_many2manytags_box {
|
||||
display: none; /* display it only after the names have been set - cf. portal_project_issue.js */
|
||||
border-radius: 2px;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-ms-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
float: left;
|
||||
border: 1px solid #9DACCC;
|
||||
background: #E2E6F0;
|
||||
color: black;
|
||||
padding: 0px 3px 0px 3px;
|
||||
margin: 0 2px 2px 0;
|
||||
height: 16px;
|
||||
font: 11px "lucida grande", tahoma, verdana, arial, sans-serif;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
openerp.portal_project_issue = function(openerp) {
|
||||
openerp.web_kanban.KanbanView.include({
|
||||
on_groups_started: function() {
|
||||
var self = this;
|
||||
self._super.apply(this, arguments);
|
||||
|
||||
if (this.dataset.model === 'project.issue' || this.dataset.model === 'project.task') {
|
||||
/*
|
||||
* Set proper names to project categories.
|
||||
* In kanban views, many2many fields only return a list of ids.
|
||||
* Therefore, we have to fetch the matching data by ourselves.
|
||||
*/
|
||||
var categ_ids = [];
|
||||
|
||||
// Collect categories ids
|
||||
this.$element.find('.oe_form_field_many2manytags_box').each(function() {
|
||||
categ_ids.push($(this).data('categ_id'));
|
||||
});
|
||||
|
||||
// Find their matching names
|
||||
var dataset = new openerp.web.DataSetSearch(this, 'project.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('.oe_form_field_many2manytags_box[data-categ_id=' + v.id + ']').text(v.name).toggle();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user