[FIX] web: prevent crash in kanban in some cases
Before this commit, if a user tries to group a kanban view by a date or a datetime interval, then tries to drag and drop a record from one column to another, then the web client crashes. This is actually an invalid operation, and is supposed to be disallowed. There is already some code that properly handle the situation. However, the field attribute was not properly read in the case of fields of type date/datetime. Related to Issue: #1911975 Co-authored-by: Mohammed Shekha <msh@openerp.com> closes odoo/odoo#30029
This commit is contained in:
committed by
Géry Debongnie
co-authored by
Mohammed Shekha
parent
6be112ac2c
commit
ccb2fffc65
@@ -436,7 +436,8 @@ var KanbanRenderer = BasicRenderer.extend({
|
||||
_setState: function (state) {
|
||||
this.state = state;
|
||||
|
||||
var groupByField = state.groupedBy[0];
|
||||
// split groupedBy field with ':' as it can be date/datetime field
|
||||
var groupByField = state.groupedBy.length && state.groupedBy[0].split(":")[0];
|
||||
var groupByFieldAttrs = state.fields[groupByField];
|
||||
var groupByFieldInfo = state.fieldsInfo.kanban[groupByField];
|
||||
// Deactivate the drag'n'drop if the groupedBy field:
|
||||
|
||||
@@ -2470,6 +2470,45 @@ QUnit.module('Views', {
|
||||
kanban.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('prevent drag and drop if grouped by date/datetime field', function (assert) {
|
||||
assert.expect(5);
|
||||
|
||||
this.data.partner.records[0].date = '2017-01-08';
|
||||
this.data.partner.records[1].date = '2017-01-09';
|
||||
this.data.partner.records[2].date = '2017-02-08';
|
||||
this.data.partner.records[3].date = '2017-02-10';
|
||||
|
||||
var kanban = createView({
|
||||
View: KanbanView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<kanban class="o_kanban_test">' +
|
||||
'<field name="bar"/>' +
|
||||
'<templates><t t-name="kanban-box">' +
|
||||
'<div><field name="foo"/></div>' +
|
||||
'</t></templates></kanban>',
|
||||
groupBy: ['date:month'],
|
||||
});
|
||||
|
||||
assert.strictEqual(kanban.$('.o_kanban_group').length, 2, "should have 2 columns");
|
||||
assert.strictEqual(kanban.$('.o_kanban_group:nth-child(1) .o_kanban_record').length, 2,
|
||||
"1st column should contain 2 records of January month");
|
||||
assert.strictEqual(kanban.$('.o_kanban_group:nth-child(2) .o_kanban_record').length , 2,
|
||||
"2nd column should contain 2 records of February month");
|
||||
|
||||
// drag&drop a record in another column
|
||||
var $record = kanban.$('.o_kanban_group:nth-child(1) .o_kanban_record:first');
|
||||
var $group = kanban.$('.o_kanban_group:nth-child(2)');
|
||||
testUtils.dragAndDrop($record, $group);
|
||||
|
||||
// should not drag&drop record
|
||||
assert.strictEqual(kanban.$('.o_kanban_group:nth-child(1) .o_kanban_record').length , 2,
|
||||
"Should remain same records in first column(2 records)");
|
||||
assert.strictEqual(kanban.$('.o_kanban_group:nth-child(2) .o_kanban_record').length , 2,
|
||||
"Should remain same records in 2nd column(2 record)");
|
||||
kanban.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('kanban view with default_group_by', function (assert) {
|
||||
assert.expect(7);
|
||||
this.data.partner.records.product_id = 1;
|
||||
|
||||
Reference in New Issue
Block a user