[FIX] web: allow creating new kanban columns with progressbar

Before this fix, trying to create a column in a kanban view where there
were progressbars was opening a traceback. This was because the newly
create column is made from data which are guessed in the client (no RPC
is done), so this guess had to be adapted to progressbars.
This commit is contained in:
qsm-odoo
2017-09-29 12:26:50 +02:00
parent f92601704e
commit 7dbf6d2154
2 changed files with 39 additions and 0 deletions
@@ -79,6 +79,11 @@ var KanbanModel = BasicModel.extend({
value: result,
viewType: parent.viewType,
});
if (parent.progressBar) {
newGroup.progressBarValues = _.extend({
counts: {},
}, parent.progressBar);
}
// newGroup.is_open = true;
parent.data.push(newGroup.id);
@@ -2024,6 +2024,40 @@ QUnit.module('Views', {
kanban.destroy();
});
QUnit.test('column progressbars: creating a new column should create a new progressbar', function (assert) {
assert.expect(1);
var kanban = createView({
View: KanbanView,
model: 'partner',
data: this.data,
arch:
'<kanban>' +
'<field name="product_id"/>' +
'<progressbar field="foo" colors=\'{"yop": "success", "gnap": "warning", "blip": "danger"}\'/>' +
'<templates><t t-name="kanban-box">' +
'<div>' +
'<field name="name"/>' +
'</div>' +
'</t></templates>' +
'</kanban>',
groupBy: ['product_id'],
});
var nbProgressBars = kanban.$('.o_kanban_counter').length;
// Create a new column: this should create an empty progressbar
var $columnQuickCreate = kanban.$('.o_column_quick_create');
$columnQuickCreate.click();
$columnQuickCreate.find('input').val('test');
$columnQuickCreate.find('.btn-primary').click();
assert.strictEqual(kanban.$('.o_kanban_counter').length, nbProgressBars + 1,
"a new column with a new column progressbar should have been created");
kanban.destroy();
});
QUnit.test('keep adding quickcreate in first column after a record from this column was moved', function (assert) {
assert.expect(2);