[FIX] web: click on many2many tag with no color
Before this rev., a traceback was raised when the user clicked on a many2many tag in a kanban view without color field. For instance, it was the case in the kanban view opened by clicking on the Lead/Opportunity section of the activities icon in the systray.
This commit is contained in:
@@ -1678,6 +1678,7 @@ var KanbanFieldMany2ManyTags = FieldMany2ManyTags.extend({
|
||||
_.each(this.value.data, function (m2m) {
|
||||
var $tag = $('<span>')
|
||||
.text(m2m.data.display_name)
|
||||
.data('res_id', m2m.res_id)
|
||||
.prepend('<span>')
|
||||
.appendTo(self.$el);
|
||||
if (self.colorField in m2m.data) {
|
||||
@@ -1686,7 +1687,6 @@ var KanbanFieldMany2ManyTags = FieldMany2ManyTags.extend({
|
||||
$tag.hide();
|
||||
} else {
|
||||
$tag.addClass('o_tag o_tag_color_' + m2m.data[self.colorField]);
|
||||
$tag.data('res_id', m2m.res_id);
|
||||
}
|
||||
} else {
|
||||
// display tags in grey by default
|
||||
|
||||
@@ -564,6 +564,43 @@ QUnit.module('Views', {
|
||||
kanban.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('many2many_tags with no color field and search by tag', function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
delete this.data.category.fields.color;
|
||||
this.data.partner.records[0].category_ids = [6, 7];
|
||||
|
||||
var kanban = createView({
|
||||
View: KanbanView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<kanban><templates><t t-name="kanban-box">' +
|
||||
'<div>' +
|
||||
'<field name="category_ids" widget="many2many_tags"/>' +
|
||||
'<field name="foo"/>' +
|
||||
'</div>' +
|
||||
'</t></templates></kanban>',
|
||||
intercepts: {
|
||||
add_filter: function (event) {
|
||||
assert.deepEqual(event.data, {
|
||||
domain: "[['category_ids','=','gold']]",
|
||||
help: 'gold',
|
||||
}, "should trigger an 'add_filter' event with correct data");
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
var $first_record = kanban.$('.o_kanban_record:first()');
|
||||
assert.strictEqual($first_record.find('.o_field_many2manytags .o_tag').length, 2,
|
||||
'first record should contain 2 tags');
|
||||
assert.ok($first_record.find('.o_tag.o_tag_color_0').hasClass('o_tag_color_0'),
|
||||
'both tags should have the default color');
|
||||
// click on a tag to trigger a search by tag
|
||||
kanban.$('.o_tag:contains(gold):first').click();
|
||||
|
||||
kanban.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('can drag and drop a record from one column to the next', function (assert) {
|
||||
assert.expect(9);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user