' +
+ '',
+ groupBy: ['bar'],
+ mockRPC: function (route, args) {
+ assert.step(args.method || route);
+ if (args.method === 'name_create') {
+ assert.strictEqual(args.args[0], 'new partner',
+ "should send the correct value");
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+
+ assert.strictEqual(kanban.$('.o_kanban_group:first .o_kanban_record').length, 1,
+ "first column should contain one record");
+
+ // click on 'Create' -> should open the quick create in the first column
+ kanban.$buttons.find('.o-kanban-button-new').click();
+ var $quickCreate = kanban.$('.o_kanban_group:first .o_kanban_quick_create');
+
+ assert.strictEqual($quickCreate.length, 1,
+ "should have a quick create element in the first column");
+ assert.strictEqual($quickCreate.find('.o_form_view.o_xxs_form_view').length, 1,
+ "should have rendered an XXS form view");
+ assert.strictEqual($quickCreate.find('input').length, 1,
+ "should have only one input");
+ assert.ok($quickCreate.find('input').hasClass('o_required_modifier'),
+ "the field should be required");
+ assert.strictEqual($quickCreate.find('input[placeholder=Title]').length, 1,
+ "input placeholder should be 'Title'");
+
+ // fill the quick create and validate
+ $quickCreate.find('input').val('new partner').trigger('input');
+ $quickCreate.find('button.o_kanban_add').click();
+
+ assert.strictEqual(kanban.$('.o_kanban_group:first .o_kanban_record').length, 2,
+ "first column should contain two records");
+
+ assert.verifySteps([
+ 'read_group', // initial read_group
+ '/web/dataset/search_read', // initial search_read (first column)
+ '/web/dataset/search_read', // initial search_read (second column)
+ 'default_get', // quick create
+ 'name_create', // should perform a name_create to create the record
+ 'read', // read the created record
+ 'default_get', // reopen the quick create automatically
+ ]);
+
+ kanban.destroy();
+ });
+
+ QUnit.test('quick create record with quick_create_view', function (assert) {
+ assert.expect(17);
+
+ var kanban = createView({
+ View: KanbanView,
+ model: 'partner',
+ data: this.data,
+ arch: '' +
+ '' +
+ '' +
+ '
' +
+ '',
+ archs: {
+ 'partner,some_view_ref,form': '',
+ },
+ groupBy: ['bar'],
+ mockRPC: function (route, args) {
+ assert.step(args.method || route);
+ if (args.method === 'create') {
+ assert.deepEqual(args.args[0], {
+ foo: 'new partner',
+ int_field: 4,
+ state: 'def',
+ }, "should send the correct values");
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+
+ assert.strictEqual(kanban.$('.o_kanban_group:first .o_kanban_record').length, 1,
+ "first column should contain one record");
+
+ // click on 'Create' -> should open the quick create in the first column
+ kanban.$buttons.find('.o-kanban-button-new').click();
+ var $quickCreate = kanban.$('.o_kanban_group:first .o_kanban_quick_create');
+
+ assert.strictEqual($quickCreate.length, 1,
+ "should have a quick create element in the first column");
+ assert.strictEqual($quickCreate.find('.o_form_view.o_xxs_form_view').length, 1,
+ "should have rendered an XXS form view");
+ assert.strictEqual($quickCreate.find('input').length, 2,
+ "should have two inputs");
+ assert.strictEqual($quickCreate.find('.o_field_widget').length, 3,
+ "should have rendered three widgets");
+
+ // fill the quick create and validate
+ $quickCreate.find('.o_field_widget[name=foo]').val('new partner').trigger('input');
+ $quickCreate.find('.o_field_widget[name=int_field]').val('4').trigger('input');
+ $quickCreate.find('.o_field_widget[name=state] .o_priority_star:first').click();
+ $quickCreate.find('button.o_kanban_add').click();
+
+ assert.strictEqual(kanban.$('.o_kanban_group:first .o_kanban_record').length, 2,
+ "first column should contain two records");
+
+ assert.verifySteps([
+ 'read_group', // initial read_group
+ '/web/dataset/search_read', // initial search_read (first column)
+ '/web/dataset/search_read', // initial search_read (second column)
+ 'load_views', // form view in quick create
+ 'default_get', // quick create
+ 'create', // should perform a create to create the record
+ 'read', // read the created record
+ 'load_views', // form view in quick create (is actually in cache)
+ 'default_get', // reopen the quick create automatically
+ ]);
+
+ kanban.destroy();
+ });
+
+ QUnit.test('quick create record in grouped on m2o (no quick_create_view)', function (assert) {
+ assert.expect(12);
+
+ var kanban = createView({
+ View: KanbanView,
+ model: 'partner',
+ data: this.data,
+ arch: '' +
+ '' +
+ '' +
+ '
' +
+ '' +
+ '',
+ groupBy: ['product_id'],
+ mockRPC: function (route, args) {
+ assert.step(args.method || route);
+ if (args.method === 'name_create') {
+ assert.strictEqual(args.args[0], 'new partner',
+ "should send the correct value");
+ assert.deepEqual(args.kwargs.context, {
+ default_product_id: 3,
+ default_qux: 2.5,
+ }, "should send the correct context");
+ }
+ return this._super.apply(this, arguments);
+ },
+ viewOptions: {
+ context: {default_qux: 2.5},
+ },
+ });
+
+ assert.strictEqual(kanban.$('.o_kanban_group:first .o_kanban_record').length, 2,
+ "first column should contain two records");
+
+ // click on 'Create', fill the quick create and validate
+ kanban.$buttons.find('.o-kanban-button-new').click();
+ var $quickCreate = kanban.$('.o_kanban_group:first .o_kanban_quick_create');
+ $quickCreate.find('input').val('new partner').trigger('input');
+ $quickCreate.find('button.o_kanban_add').click();
+
+ assert.strictEqual(kanban.$('.o_kanban_group:first .o_kanban_record').length, 3,
+ "first column should contain three records");
+
+ assert.verifySteps([
+ 'read_group', // initial read_group
+ '/web/dataset/search_read', // initial search_read (first column)
+ '/web/dataset/search_read', // initial search_read (second column)
+ 'default_get', // quick create
+ 'name_create', // should perform a name_create to create the record
+ 'read', // read the created record
+ 'default_get', // reopen the quick create automatically
+ ]);
+
+ kanban.destroy();
+ });
+
+ QUnit.test('quick create record in grouped on m2o (with quick_create_view)', function (assert) {
+ assert.expect(14);
+
+ var kanban = createView({
+ View: KanbanView,
+ model: 'partner',
+ data: this.data,
+ arch: '' +
+ '' +
+ '' +
+ '
' +
+ '',
+ archs: {
+ 'partner,some_view_ref,form': '',
+ },
+ groupBy: ['product_id'],
+ mockRPC: function (route, args) {
+ assert.step(args.method || route);
+ if (args.method === 'create') {
+ assert.deepEqual(args.args[0], {
+ foo: 'new partner',
+ int_field: 4,
+ state: 'def',
+ }, "should send the correct values");
+ assert.deepEqual(args.kwargs.context, {
+ default_product_id: 3,
+ default_qux: 2.5,
+ }, "should send the correct context");
+ }
+ return this._super.apply(this, arguments);
+ },
+ viewOptions: {
+ context: {default_qux: 2.5},
+ },
+ });
+
+ assert.strictEqual(kanban.$('.o_kanban_group:first .o_kanban_record').length, 2,
+ "first column should contain two records");
+
+ // click on 'Create', fill the quick create and validate
+ kanban.$buttons.find('.o-kanban-button-new').click();
+ var $quickCreate = kanban.$('.o_kanban_group:first .o_kanban_quick_create');
+ $quickCreate.find('.o_field_widget[name=foo]').val('new partner').trigger('input');
+ $quickCreate.find('.o_field_widget[name=int_field]').val('4').trigger('input');
+ $quickCreate.find('.o_field_widget[name=state] .o_priority_star:first').click();
+ $quickCreate.find('button.o_kanban_add').click();
+
+ assert.strictEqual(kanban.$('.o_kanban_group:first .o_kanban_record').length, 3,
+ "first column should contain three records");
+
+ assert.verifySteps([
+ 'read_group', // initial read_group
+ '/web/dataset/search_read', // initial search_read (first column)
+ '/web/dataset/search_read', // initial search_read (second column)
+ 'load_views', // form view in quick create
+ 'default_get', // quick create
+ 'create', // should perform a create to create the record
+ 'read', // read the created record
+ 'load_views', // form view in quick create (is actually in cache)
+ 'default_get', // reopen the quick create automatically
+ ]);
+
+ kanban.destroy();
+ });
+
+ QUnit.test('quick create record with default values and onchanges', function (assert) {
+ assert.expect(11);
+
+ this.data.partner.fields.int_field.default = 4;
+ this.data.partner.onchanges = {
+ foo: function (obj) {
+ if (obj.foo) {
+ obj.int_field = 8;
+ }
+ },
+ };
+
+ var kanban = createView({
+ View: KanbanView,
+ model: 'partner',
+ data: this.data,
+ arch: '' +
+ '' +
+ '' +
+ '
' +
+ '',
+ archs: {
+ 'partner,some_view_ref,form': '',
+ },
+ groupBy: ['bar'],
+ mockRPC: function (route, args) {
+ assert.step(args.method || route);
+ return this._super.apply(this, arguments);
+ },
+ });
+
+ // click on 'Create' -> should open the quick create in the first column
+ kanban.$buttons.find('.o-kanban-button-new').click();
+ var $quickCreate = kanban.$('.o_kanban_group:first .o_kanban_quick_create');
+
+ assert.strictEqual($quickCreate.length, 1,
+ "should have a quick create element in the first column");
+ assert.strictEqual($quickCreate.find('.o_field_widget[name=int_field]').val(), '4',
+ "default value should be set");
+
+ // fill the 'foo' field -> should trigger the onchange
+ $quickCreate.find('.o_field_widget[name=foo]').val('new partner').trigger('input');
+
+ assert.strictEqual($quickCreate.find('.o_field_widget[name=int_field]').val(), '8',
+ "onchange should have been triggered");
+
+ assert.verifySteps([
+ 'read_group', // initial read_group
+ '/web/dataset/search_read', // initial search_read (first column)
+ '/web/dataset/search_read', // initial search_read (second column)
+ 'load_views', // form view in quick create
+ 'default_get', // quick create
+ 'onchange', // default_get's onchange
+ 'onchange', // onchange due to 'foo' field change
+ ]);
+
+ kanban.destroy();
+ });
+
+ QUnit.test('quick create record with quick_create_view: modifiers', function (assert) {
+ assert.expect(3);
+
+ var kanban = createView({
+ View: KanbanView,
+ model: 'partner',
+ data: this.data,
+ arch: '' +
+ '' +
+ '' +
+ '
' +
+ '',
+ archs: {
+ 'partner,some_view_ref,form': '',
+ },
+ groupBy: ['bar'],
+ });
+
+ // create a new record
+ kanban.$('.o_kanban_group:first .o_kanban_quick_add').click();
+ var $quickCreate = kanban.$('.o_kanban_group:first .o_kanban_quick_create');
+
+ assert.ok($quickCreate.find('.o_field_widget[name=foo]').hasClass('o_required_modifier'),
+ "foo field should be required");
+ assert.ok($quickCreate.find('.o_field_widget[name=int_field]').hasClass('o_invisible_modifier'),
+ "int_field should be invisible");
+
+ // fill 'foo' field
+ $quickCreate.find('.o_field_widget[name=foo]').val('new partner').trigger('input');
+
+ assert.notOk($quickCreate.find('.o_field_widget[name=int_field]').hasClass('o_invisible_modifier'),
+ "int_field should now be visible");
+
+ kanban.destroy();
+ });
+
+ QUnit.test('quick create record and change state in grouped mode', function (assert) {
assert.expect(1);
this.data.partner.fields.kanban_state = {
@@ -369,7 +728,7 @@ QUnit.module('Views', {
kanban.destroy();
});
- QUnit.test('quick create in grouped mode', function (assert) {
+ QUnit.test('quick create record: cancel and validate without using the buttons', function (assert) {
assert.expect(8);
var nbRecords = 4;
@@ -377,7 +736,7 @@ QUnit.module('Views', {
View: KanbanView,
model: 'partner',
data: this.data,
- arch: '' +
+ arch: '' +
'' +
'' +
'
' +
@@ -391,34 +750,41 @@ QUnit.module('Views', {
}
});
- // click to add an element and cancel the quick creation
+ // click to add an element and cancel the quick creation by pressing ESC
kanban.$('.o_kanban_header .o_kanban_quick_add i').first().click();
var $quickCreate = kanban.$('.o_kanban_quick_create');
assert.strictEqual($quickCreate.length, 1, "should have a quick create element");
- $quickCreate.find('input').trigger($.Event('keydown', {keyCode: $.ui.keyCode.ESCAPE}));
+ $quickCreate.find('input').trigger($.Event('keydown', {
+ keyCode: $.ui.keyCode.ESCAPE,
+ which: $.ui.keyCode.ESCAPE,
+ }));
assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 0,
"should have destroyed the quick create element");
- //click to add and element and focus out the blank input, should cancel the quick creation
+ // click to add and element and click outside, should cancel the quick creation
kanban.$('.o_kanban_header .o_kanban_quick_add i').first().click();
- $quickCreate = kanban.$('.o_kanban_quick_create');
- $quickCreate.find('input').blur();
+ kanban.$('.o_kanban_group .o_kanban_record:first').click();
assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 0,
- "Blur should have destroyed the quick create element");
+ "the quick create should be destroyed when the user clicks outside");
// click to really add an element
kanban.$('.o_kanban_header .o_kanban_quick_add i').first().click();
$quickCreate = kanban.$('.o_kanban_quick_create');
- $quickCreate.find('input').val('new partner');
- $quickCreate.find('input').blur();
+ $quickCreate.find('input').val('new partner').trigger('input');
- // When focus out the input containing value, should not delete the Quick Creation
+ // clicking outside should no longer destroy the quick create as it is dirty
+ kanban.$('.o_kanban_group .o_kanban_record:first').click();
assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 1,
- "Blur should not have destroyed the quick create element");
+ "the quick create should not have been destroyed");
+
+ // confirm by pressing ENTER
nbRecords = 5;
- $quickCreate.find('button.o_kanban_add').click();
+ $quickCreate.find('input').trigger($.Event('keydown', {
+ keyCode: $.ui.keyCode.ENTER,
+ which: $.ui.keyCode.ENTER,
+ }));
assert.strictEqual(this.data.partner.records.length, 5,
"should have created a partner");
@@ -472,7 +838,128 @@ QUnit.module('Views', {
kanban.destroy();
});
- QUnit.test('quick create and edit in grouped mode', function (assert) {
+ QUnit.test('quick create record: cancel when not dirty', function (assert) {
+ assert.expect(9);
+
+ var kanban = createView({
+ View: KanbanView,
+ model: 'partner',
+ data: this.data,
+ arch: '' +
+ '' +
+ '' +
+ '
' +
+ '',
+ groupBy: ['bar'],
+ });
+
+ assert.strictEqual(kanban.$('.o_kanban_group:first .o_kanban_record').length, 1,
+ "first column should contain one record");
+
+ // click to add an element
+ kanban.$('.o_kanban_header .o_kanban_quick_add i').first().click();
+ assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 1,
+ "should have open the quick create widget");
+
+ // click again to add an element -> should have kept the quick create open
+ kanban.$('.o_kanban_header .o_kanban_quick_add i').first().click();
+ assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 1,
+ "should have kept the quick create open");
+
+ // click outside: should remove the quick create
+ kanban.$('.o_kanban_group .o_kanban_record:first').click();
+ assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 0,
+ "the quick create should not have been destroyed");
+
+ // click to reopen the quick create
+ kanban.$('.o_kanban_header .o_kanban_quick_add i').first().click();
+ assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 1,
+ "should have open the quick create widget");
+
+ // press ESC: should remove the quick create
+ kanban.$('.o_kanban_quick_create input').trigger($.Event('keydown', {
+ keyCode: $.ui.keyCode.ESCAPE,
+ which: $.ui.keyCode.ESCAPE,
+ }));
+ assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 0,
+ "quick create widget should have been removed");
+
+ // click to reopen the quick create
+ kanban.$('.o_kanban_header .o_kanban_quick_add i').first().click();
+ assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 1,
+ "should have open the quick create widget");
+
+ // click on 'Discard': should remove the quick create
+ kanban.$('.o_kanban_header .o_kanban_quick_add i').first().click();
+ kanban.$('.o_kanban_group .o_kanban_record:first').click();
+ assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 0,
+ "the quick create should be destroyed when the user clicks outside");
+
+ assert.strictEqual(kanban.$('.o_kanban_group:first .o_kanban_record').length, 1,
+ "first column should still contain one record");
+
+ kanban.destroy();
+ });
+
+ QUnit.test('quick create record: cancel when dirty', function (assert) {
+ assert.expect(7);
+
+ var kanban = createView({
+ View: KanbanView,
+ model: 'partner',
+ data: this.data,
+ arch: '' +
+ '' +
+ '' +
+ '
' +
+ '',
+ groupBy: ['bar'],
+ });
+
+ assert.strictEqual(kanban.$('.o_kanban_group:first .o_kanban_record').length, 1,
+ "first column should contain one record");
+
+ // click to add an element and edit it
+ kanban.$('.o_kanban_header .o_kanban_quick_add i').first().click();
+ assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 1,
+ "should have open the quick create widget");
+
+ var $quickCreate = kanban.$('.o_kanban_quick_create');
+ $quickCreate.find('input').val('some value').trigger('input');
+
+ // click outside: should not remove the quick create
+ kanban.$('.o_kanban_group .o_kanban_record:first').click();
+ assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 1,
+ "the quick create should not have been destroyed");
+
+ // press ESC: should remove the quick create
+ $quickCreate.find('input').trigger($.Event('keydown', {
+ keyCode: $.ui.keyCode.ESCAPE,
+ which: $.ui.keyCode.ESCAPE,
+ }));
+ assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 0,
+ "quick create widget should have been removed");
+
+ // click to reopen quick create and edit it
+ kanban.$('.o_kanban_header .o_kanban_quick_add i').first().click();
+ assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 1,
+ "should have open the quick create widget");
+
+ $quickCreate = kanban.$('.o_kanban_quick_create');
+ $quickCreate.find('input').val('some value').trigger('input');
+
+ // click on 'Discard': should remove the quick create
+ kanban.$('.o_kanban_quick_create .o_kanban_cancel').click();
+ assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 0,
+ "the quick create should be destroyed when the user clicks outside");
+
+ assert.strictEqual(kanban.$('.o_kanban_group:first .o_kanban_record').length, 1,
+ "first column should still contain one record");
+
+ kanban.destroy();
+ });
+
+ QUnit.test('quick create record and edit in grouped mode', function (assert) {
assert.expect(6);
var newRecordID;
@@ -512,7 +999,7 @@ QUnit.module('Views', {
var $quickCreate = kanban.$('.o_kanban_quick_create');
kanban.$('.o_kanban_header .o_kanban_quick_add i').first().click();
$quickCreate = kanban.$('.o_kanban_quick_create');
- $quickCreate.find('input').val('new partner');
+ $quickCreate.find('input').val('new partner').trigger('input');
$quickCreate.find('button.o_kanban_edit').click();
assert.strictEqual(this.data.partner.records.length, 5,
@@ -551,7 +1038,8 @@ QUnit.module('Views', {
kanban.$('.o_kanban_quick_create input')
.val('new partner 1')
- .trigger($.Event('keypress', {
+ .trigger('input')
+ .trigger($.Event('keydown', {
which: $.ui.keyCode.ENTER,
keyCode: $.ui.keyCode.ENTER,
}));
@@ -564,7 +1052,8 @@ QUnit.module('Views', {
// create a second element in a row
kanban.$('.o_kanban_quick_create input')
.val('new partner 2')
- .trigger($.Event('keypress', {
+ .trigger('input')
+ .trigger($.Event('keydown', {
which: $.ui.keyCode.ENTER,
keyCode: $.ui.keyCode.ENTER,
}));
@@ -623,7 +1112,8 @@ QUnit.module('Views', {
def = $.Deferred();
kanban.$('.o_kanban_quick_create input')
.val('new partner 1')
- .trigger($.Event('keypress', {
+ .trigger('input')
+ .trigger($.Event('keydown', {
which: $.ui.keyCode.ENTER,
keyCode: $.ui.keyCode.ENTER,
}));
@@ -631,7 +1121,8 @@ QUnit.module('Views', {
def = null;
kanban.$('.o_kanban_quick_create input')
.val('new partner 2')
- .trigger($.Event('keypress', {
+ .trigger('input')
+ .trigger($.Event('keydown', {
which: $.ui.keyCode.ENTER,
keyCode: $.ui.keyCode.ENTER,
}));
@@ -651,7 +1142,7 @@ QUnit.module('Views', {
kanban.destroy();
});
- QUnit.test('quick create fail in grouped', function (assert) {
+ QUnit.test('quick create record fail in grouped', function (assert) {
assert.expect(7);
var kanban = createView({
@@ -692,7 +1183,11 @@ QUnit.module('Views', {
kanban.$('.o_kanban_quick_create input')
.val('test')
- .trigger($.Event('keypress', {keyCode: $.ui.keyCode.ENTER}));
+ .trigger('input')
+ .trigger($.Event('keydown', {
+ keyCode: $.ui.keyCode.ENTER,
+ which: $.ui.keyCode.ENTER,
+ }));
assert.strictEqual($('.modal .o_form_view.o_form_editable').length, 1,
"a form view dialog should have been opened (in edit)");
@@ -1142,17 +1637,20 @@ QUnit.module('Views', {
assert.notOk(kanban.$('.o_column_quick_create input').is(':visible'),
"the input should not be visible");
- kanban.$('.o_column_quick_create').click();
+ kanban.$('.o_quick_create_folded').click();
assert.ok(kanban.$('.o_column_quick_create input').is(':visible'),
"the input should be visible");
// discard the column creation and click it again
- kanban.$('.o_column_quick_create').click();
+ kanban.$('.o_column_quick_create input').trigger($.Event('keydown', {
+ keyCode: $.ui.keyCode.ESCAPE,
+ which: $.ui.keyCode.ESCAPE,
+ }));
assert.notOk(kanban.$('.o_column_quick_create input').is(':visible'),
"the input should not be visible after discard");
- kanban.$('.o_column_quick_create').click();
+ kanban.$('.o_quick_create_folded').click();
assert.ok(kanban.$('.o_column_quick_create input').is(':visible'),
"the input should be visible");
@@ -1183,37 +1681,6 @@ QUnit.module('Views', {
kanban.destroy();
});
- QUnit.test('quick create record & column in grouped on m2o', function (assert) {
- assert.expect(2);
-
- var kanban = createView({
- View: KanbanView,
- model: 'partner',
- data: this.data,
- arch: '' +
- '' +
- '' +
- '
' +
- '' +
- '',
- groupBy: ['product_id'],
- });
- kanban.$('.o_kanban_group:first .o_kanban_quick_add').click();
- var $quickCreate = kanban.$('.o_kanban_quick_create');
- $quickCreate.find('input').val('new partner');
- $quickCreate.find('button.o_kanban_add').click();
- assert.strictEqual(this.data.partner.records.length, 5,
- "should have created a partner");
-
- kanban.$('.o_column_quick_create').click();
- kanban.$('.o_column_quick_create input').val('new column');
- kanban.$('.o_column_quick_create button.o_kanban_add').click();
-
- assert.strictEqual(kanban.$('.o_kanban_group:last span:contains(new column)').length, 1,
- "the last column should be the newly created one");
- kanban.destroy();
- });
-
QUnit.test('delete a column in grouped on m2o', function (assert) {
assert.expect(28);
@@ -1425,6 +1892,147 @@ QUnit.module('Views', {
kanban.destroy();
});
+ QUnit.test('quick create column should be opened if there is no column', function (assert) {
+ assert.expect(3);
+
+ var kanban = createView({
+ View: KanbanView,
+ model: 'partner',
+ data: this.data,
+ arch: '' +
+ '' +
+ '' +
+ '
' +
+ '' +
+ '',
+ groupBy: ['product_id'],
+ domain: [['foo', '=', 'norecord']],
+ });
+
+ assert.strictEqual(kanban.$('.o_kanban_group').length, 0,
+ "there should be no column");
+ assert.strictEqual(kanban.$('.o_column_quick_create').length, 1,
+ "should have a quick create column");
+ assert.ok(kanban.$('.o_column_quick_create input').is(':visible'),
+ "the quick create should be opened");
+
+ kanban.destroy();
+ });
+
+ QUnit.test('quick create several columns in a row', function (assert) {
+ assert.expect(10);
+
+ var kanban = createView({
+ View: KanbanView,
+ model: 'partner',
+ data: this.data,
+ arch: '' +
+ '' +
+ '' +
+ '
' +
+ '' +
+ '',
+ groupBy: ['product_id'],
+ });
+
+ assert.strictEqual(kanban.$('.o_kanban_group').length, 2,
+ "should have two columns");
+ assert.strictEqual(kanban.$('.o_column_quick_create').length, 1,
+ "should have a ColumnQuickCreate widget");
+ assert.strictEqual(kanban.$('.o_column_quick_create .o_quick_create_folded:visible').length, 1,
+ "the ColumnQuickCreate should be folded");
+ assert.strictEqual(kanban.$('.o_column_quick_create .o_quick_create_unfolded:visible').length, 0,
+ "the ColumnQuickCreate should be folded");
+
+ // add a new column
+ kanban.$('.o_column_quick_create .o_quick_create_folded').click();
+ assert.strictEqual(kanban.$('.o_column_quick_create .o_quick_create_folded:visible').length, 0,
+ "the ColumnQuickCreate should be unfolded");
+ assert.strictEqual(kanban.$('.o_column_quick_create .o_quick_create_unfolded:visible').length, 1,
+ "the ColumnQuickCreate should be unfolded");
+ kanban.$('.o_column_quick_create input').val('New Column 1');
+ kanban.$('.o_column_quick_create .btn-primary').click();
+ assert.strictEqual(kanban.$('.o_kanban_group').length, 3,
+ "should now have three columns");
+
+ // add another column
+ assert.strictEqual(kanban.$('.o_column_quick_create .o_quick_create_folded:visible').length, 0,
+ "the ColumnQuickCreate should still be unfolded");
+ assert.strictEqual(kanban.$('.o_column_quick_create .o_quick_create_unfolded:visible').length, 1,
+ "the ColumnQuickCreate should still be unfolded");
+ kanban.$('.o_column_quick_create input').val('New Column 2');
+ kanban.$('.o_column_quick_create .btn-primary').click();
+ assert.strictEqual(kanban.$('.o_kanban_group').length, 4,
+ "should now have four columns");
+
+ kanban.destroy();
+ });
+
+ QUnit.test('quick create column and examples', function (assert) {
+ assert.expect(12);
+
+ kanbanExamplesRegistry.add('test', [{
+ name: "A first example",
+ columns: ["Column 1", "Column 2", "Column 3"],
+ description: "Some description",
+ }, {
+ name: "A second example",
+ columns: ["Col 1", "Col 2"],
+ }]);
+
+ var kanban = createView({
+ View: KanbanView,
+ model: 'partner',
+ data: this.data,
+ arch: '' +
+ '' +
+ '' +
+ '
' +
+ '' +
+ '',
+ groupBy: ['product_id'],
+ });
+
+ assert.strictEqual(kanban.$('.o_column_quick_create').length, 1,
+ "should have a ColumnQuickCreate widget");
+
+ // open the quick create
+ kanban.$('.o_column_quick_create .o_quick_create_folded').click();
+
+ assert.strictEqual(kanban.$('.o_column_quick_create .o_kanban_examples:visible').length, 1,
+ "should have a link to see examples");
+
+ // click to see the examples
+ kanban.$('.o_column_quick_create .o_kanban_examples').click();
+
+ assert.strictEqual($('.modal .o_kanban_examples_dialog').length, 1,
+ "should have open the examples dialog");
+ assert.strictEqual($('.modal .o_kanban_examples_dialog_nav li').length, 2,
+ "should have two examples (in the menu)");
+ assert.strictEqual($('.modal .o_kanban_examples_dialog_nav a').text(),
+ ' A first example A second example ', "example names should be correct");
+ assert.strictEqual($('.modal .o_kanban_examples_dialog_content .tab-pane').length, 2,
+ "should have two examples");
+
+ var $firstPane = $('.modal .o_kanban_examples_dialog_content .tab-pane:first');
+ assert.strictEqual($firstPane.find('.o_kanban_examples_group').length, 3,
+ "there should be 3 stages in the first example");
+ assert.strictEqual($firstPane.find('h6').text(), 'Column 1Column 2Column 3',
+ "column titles should be correct");
+ assert.strictEqual($firstPane.find('.o_kanban_examples_description').text().trim(),
+ "Some description", "the correct description should be displayed");
+
+ var $secondPane = $('.modal .o_kanban_examples_dialog_content .tab-pane:nth(1)');
+ assert.strictEqual($secondPane.find('.o_kanban_examples_group').length, 2,
+ "there should be 2 stages in the second example");
+ assert.strictEqual($secondPane.find('h6').text(), 'Col 1Col 2',
+ "column titles should be correct");
+ assert.strictEqual($secondPane.find('.o_kanban_examples_description').text().trim(),
+ "", "there should be no description for the second example");
+
+ kanban.destroy();
+ });
+
QUnit.test('if view was grouped at start, it stays grouped', function (assert) {
assert.expect(1);
@@ -2045,15 +2653,15 @@ QUnit.module('Views', {
groupBy: ['product_id'],
});
- assert.ok(kanban.$buttons.find('.o-kanban-button-new').hasClass('btn-default'),
- "Create button shouldn't be highlighted");
+ assert.ok(kanban.$buttons.find('.o-kanban-button-new').hasClass('o_hidden'),
+ "Create button should be hidden");
kanban.$('.o_column_quick_create').click();
kanban.$('.o_column_quick_create input').val('new column');
kanban.$('.o_column_quick_create button.o_kanban_add').click();
- assert.ok(kanban.$buttons.find('.o-kanban-button-new').hasClass('btn-primary'),
- "Create button should now be highlighted");
+ assert.notOk(kanban.$buttons.find('.o-kanban-button-new').hasClass('o_hidden'),
+ "Create button should now be visible");
kanban.destroy();
});
@@ -2137,7 +2745,7 @@ QUnit.module('Views', {
kanban.$('.o_kanban_group:eq(1) .o_kanban_quick_add i').click();
var $quickCreate = kanban.$('.o_kanban_group:eq(1) .o_kanban_quick_create');
- $quickCreate.find('input').val('new partner');
+ $quickCreate.find('input').val('new partner').trigger('input');
$quickCreate.find('button.o_kanban_add').click();
assert.strictEqual(kanban.$('.o_kanban_group:eq(0) .o_kanban_record').length, 0,
@@ -2197,12 +2805,12 @@ QUnit.module('Views', {
kanban.$('.o_kanban_group:eq(0) .o_kanban_quick_add i').click();
var $quickCreate = kanban.$('.o_kanban_group:eq(0) .o_kanban_quick_create');
- $quickCreate.find('input').val('record1');
+ $quickCreate.find('input').val('record1').trigger('input');
$quickCreate.find('button.o_kanban_add').click();
kanban.$('.o_kanban_group:eq(0) .o_kanban_quick_add i').click();
$quickCreate = kanban.$('.o_kanban_group:eq(0) .o_kanban_quick_create');
- $quickCreate.find('input').val('record2');
+ $quickCreate.find('input').val('record2').trigger('input');
$quickCreate.find('button.o_kanban_add').click();
assert.strictEqual(kanban.$('.o_kanban_group:eq(0) .o_kanban_record').length, 2,
@@ -2235,35 +2843,6 @@ QUnit.module('Views', {
kanban.destroy();
});
- QUnit.test('don\'t fold column quick create after creation', function (assert) {
- assert.expect(2);
-
- var kanban = createView({
- View: KanbanView,
- model: 'partner',
- data: this.data,
- arch: '' +
- '' +
- '' +
- '
' +
- '' +
- '',
- groupBy: ['product_id'],
- });
-
- // add a new column
- kanban.$('.o_kanban_group:first .o_kanban_quick_add').click();
- var $quickCreate = kanban.$('.o_kanban_quick_create');
- $quickCreate.find('input').val('new partner');
- $quickCreate.find('button.o_kanban_add').click();
- assert.strictEqual(this.data.partner.records.length, 5,
- "should have created a 'new partner' column");
-
- assert.strictEqual(kanban.$('.o_kanban_add:visible').length, 1,
- "the add button should still be visible");
- kanban.destroy();
- });
-
QUnit.test('basic support for widgets', function (assert) {
assert.expect(1);
@@ -2379,11 +2958,11 @@ QUnit.module('Views', {
groupBy: ['bar'],
});
- var initialCount = parseInt(kanban.$('.o_kanban_counter_side').eq(1).text());
- kanban.$('.o_kanban_quick_add').eq(1).click();
- kanban.$('.o_input').val('Test');
+ var initialCount = parseInt(kanban.$('.o_kanban_counter_side:first').text());
+ kanban.$('.o_kanban_quick_add:first').click();
+ kanban.$('.o_kanban_quick_create input').val('Test').trigger('input');
kanban.$('.o_kanban_add').click();
- var lastCount = parseInt(kanban.$('.o_kanban_counter_side').eq(1).text());
+ var lastCount = parseInt(kanban.$('.o_kanban_counter_side:first').text());
assert.strictEqual(lastCount, initialCount + 1,
"kanban counters should have updated on quick create");
@@ -2420,6 +2999,45 @@ QUnit.module('Views', {
kanban.destroy();
});
+ QUnit.test('column progressbars on quick create with quick_create_view are updated', function (assert) {
+ assert.expect(1);
+
+ var kanban = createView({
+ View: KanbanView,
+ model: 'partner',
+ data: this.data,
+ arch: '' +
+ '' +
+ '' +
+ '' +
+ '
' +
+ '' +
+ '
' +
+ '' +
+ '',
+ archs: {
+ 'partner,some_view_ref,form': '',
+ },
+ groupBy: ['bar'],
+ });
+
+ var initialCount = parseInt(kanban.$('.o_kanban_counter_side:first').text());
+
+ // click on 'Create', fill the quick create and validate
+ kanban.$buttons.find('.o-kanban-button-new').click();
+ var $quickCreate = kanban.$('.o_kanban_group:first .o_kanban_quick_create');
+ $quickCreate.find('.o_field_widget[name=int_field]').val('44').trigger('input');
+ $quickCreate.find('button.o_kanban_add').click();
+
+ var lastCount = parseInt(kanban.$('.o_kanban_counter_side:first').text());
+ assert.strictEqual(lastCount, initialCount + 44,
+ "kanban counters should have been updated on quick create");
+
+ kanban.destroy();
+ });
+
QUnit.test('keep adding quickcreate in first column after a record from this column was moved', function (assert) {
assert.expect(2);
diff --git a/addons/web/views/webclient_templates.xml b/addons/web/views/webclient_templates.xml
index f6e337a8731..c78b6b0ecac 100644
--- a/addons/web/views/webclient_templates.xml
+++ b/addons/web/views/webclient_templates.xml
@@ -122,6 +122,7 @@
+
@@ -213,14 +214,17 @@
-
+
+
+
+
diff --git a/addons/web_tour/static/src/js/tour_service.js b/addons/web_tour/static/src/js/tour_service.js
index 09b4e6896b9..37e6f1a5c0f 100644
--- a/addons/web_tour/static/src/js/tour_service.js
+++ b/addons/web_tour/static/src/js/tour_service.js
@@ -12,7 +12,7 @@ var TourManager = require('web_tour.TourManager');
var QWeb = core.qweb;
-if (config.device.size_class <= config.device.SIZES.XS) {
+if (config.device.isMobile) {
return $.Deferred().reject();
}
diff --git a/addons/website/static/src/js/content/menu.js b/addons/website/static/src/js/content/menu.js
index 52e4e2c5319..5f8c337802f 100644
--- a/addons/website/static/src/js/content/menu.js
+++ b/addons/website/static/src/js/content/menu.js
@@ -113,7 +113,7 @@ sAnimation.registry.autohideMenu = sAnimation.Class.extend({
*/
_adapt: function () {
this._restore();
- if (config.device.size_class < config.device.SIZES.SM) {
+ if (config.device.isMobile) {
return;
}
diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js
index d54978e290c..874b9f698b5 100644
--- a/addons/website_sale/static/src/js/website_sale.js
+++ b/addons/website_sale/static/src/js/website_sale.js
@@ -480,7 +480,7 @@ odoo.define('website_sale.website_sale', function (require) {
});
// Deactivate image zoom for mobile devices, since it might prevent users to scroll
- if (config.device.size_class > config.device.SIZES.XS) {
+ if (!config.device.isMobile) {
$('.ecom-zoomable img[data-zoom]').zoomOdoo({ attach: '#o-carousel-product'});
}
});
diff --git a/odoo/addons/test_main_flows/static/src/js/tour.js b/odoo/addons/test_main_flows/static/src/js/tour.js
index df19f6c2df3..7b08672385c 100644
--- a/odoo/addons/test_main_flows/static/src/js/tour.js
+++ b/odoo/addons/test_main_flows/static/src/js/tour.js
@@ -248,32 +248,30 @@ tour.register('main_flow_tour', {
content: _t("Click here to create your first opportunity and add it to your pipeline."),
position: "bottom"
}, {
- trigger: ".modal-body input:first",
- content: _t("Enter the opportunity title."),
+ trigger: ".o_kanban_quick_create input:first",
+ content: _t("Choose a name for your opportunity."),
position: "right",
run: "text the_flow.opportunity",
}, {
- trigger: ".o_field_widget[name=partner_id] input",
+ trigger: ".o_kanban_quick_create .o_field_widget[name=partner_id] input",
content: _t("Write the name of your customer to create one on the fly, or select an existing one."),
position: "left",
run: "text the_flow.customer",
}, {
trigger: ".ui-menu-item > a:contains('the_flow.customer')",
- in_modal: false,
auto: true,
}, {
- trigger: ".modal-footer .btn-primary",
- extra_trigger: ".o_field_widget[name=partner_id] > .o_external_button", // Wait name_create
- content: _t("Create"),
- position: "bottom",
+ trigger: ".o_kanban_quick_create .o_kanban_add",
+ extra_trigger: ".o_kanban_quick_create .o_field_widget[name=partner_id] > .o_external_button", // Wait name_create
+ content: _t("Click here to add your opportunity."),
+ position: "right",
}, {
- trigger: ".o_kanban_group:first-child .o_kanban_record:last-child",
+ trigger: ".o_kanban_group:first .o_kanban_record:has(span:contains('the_flow.opportunity'))",
content: _t("Drag & drop opportunities between columns as you progress in your sales cycle."),
position: "right",
run: "drag_and_drop .o_opportunity_kanban .o_kanban_group:eq(2) ",
}, {
- trigger: ".o_kanban_record:has(span:contains('the_flow.opportunity'))",
- extra_trigger: ".o_kanban_group:eq(2) > .o_kanban_record:has(span:contains('the_flow.opportunity'))", // FIXME: this is required due to an issue in tour_manager (see [*])
+ trigger: ".o_kanban_group:eq(2) > .o_kanban_record:has(span:contains('the_flow.opportunity'))",
content: _t("Click on an opportunity to zoom to it."),
position: "bottom",
}, {