diff --git a/addons/web/static/src/js/views/kanban/kanban_column.js b/addons/web/static/src/js/views/kanban/kanban_column.js
index 6fea1c36d32..ef75caca8c0 100644
--- a/addons/web/static/src/js/views/kanban/kanban_column.js
+++ b/addons/web/static/src/js/views/kanban/kanban_column.js
@@ -53,6 +53,7 @@ var KanbanColumn = Widget.extend({
this.grouped_by_m2o = options.grouped_by_m2o;
this.editable = options.editable;
this.deletable = options.deletable;
+ this.archivable = options.archivable;
this.draggable = options.draggable;
this.KanbanRecord = options.KanbanRecord || KanbanRecord; // the KanbanRecord class to use
this.records_editable = options.records_editable;
diff --git a/addons/web/static/src/js/views/kanban/kanban_view.js b/addons/web/static/src/js/views/kanban/kanban_view.js
index 99be6175da3..791e3664668 100644
--- a/addons/web/static/src/js/views/kanban/kanban_view.js
+++ b/addons/web/static/src/js/views/kanban/kanban_view.js
@@ -61,6 +61,7 @@ var KanbanView = BasicView.extend({
this.rendererParams.column_options = {
editable: activeActions.group_edit,
deletable: activeActions.group_delete,
+ archivable: this.arch.attrs.archivable ? JSON.parse(this.arch.attrs.archivable) : true,
group_creatable: activeActions.group_create && !config.device.isMobile,
quick_create: params.isQuickCreateEnabled || this._isQuickCreateEnabled(),
quickCreateView: this.arch.attrs.quick_create_view || null,
diff --git a/addons/web/static/src/xml/kanban.xml b/addons/web/static/src/xml/kanban.xml
index adc213999f2..b91b8844752 100644
--- a/addons/web/static/src/xml/kanban.xml
+++ b/addons/web/static/src/xml/kanban.xml
@@ -23,7 +23,7 @@
Edit Stage
Delete
-
+
Archive All
Unarchive All
diff --git a/addons/web/static/tests/views/kanban_tests.js b/addons/web/static/tests/views/kanban_tests.js
index c967b42a332..1fbe683187d 100644
--- a/addons/web/static/tests/views/kanban_tests.js
+++ b/addons/web/static/tests/views/kanban_tests.js
@@ -148,7 +148,7 @@ QUnit.module('Views', {
kanban.destroy();
});
- QUnit.test('basic grouped rendering with active field', function (assert) {
+ QUnit.test('basic grouped rendering with active field (archivable by default)', function (assert) {
assert.expect(9);
// add active field on partner model and make all records active
@@ -193,6 +193,75 @@ QUnit.module('Views', {
kanban.destroy();
});
+ QUnit.test('basic grouped rendering with active field and archive enabled (archivable true)', function (assert) {
+ assert.expect(7);
+
+ // add active field on partner model and make all records active
+ this.data.partner.fields.active = {string: 'Active', type: 'char', default: true};
+
+ var envIDs = [1, 2, 3, 4]; // the ids that should be in the environment during this test
+ var kanban = createView({
+ View: KanbanView,
+ model: 'partner',
+ data: this.data,
+ arch: '' +
+ '' +
+ '' +
+ '' +
+ '
' +
+ '',
+ groupBy: ['bar'],
+ });
+
+ // check archive/restore all actions in kanban header's config dropdown
+ assert.ok(kanban.$('.o_kanban_header:first .o_kanban_config .o_column_archive_records').length, "should be able to archive all the records");
+ assert.ok(kanban.$('.o_kanban_header:first .o_kanban_config .o_column_unarchive_records').length, "should be able to restore all the records");
+
+ // archive the records of the first column
+ assert.strictEqual(kanban.$('.o_kanban_group:last .o_kanban_record').length, 3,
+ "last column should contain 3 records");
+ envIDs = [4];
+ kanban.$('.o_kanban_group:last .o_column_archive_records').click(); // Click on 'Archive All'
+ assert.ok($('.modal').length, 'a confirm modal should be displayed');
+ $('.modal-footer .btn-secondary').click(); // Click on 'Cancel'
+ assert.strictEqual(kanban.$('.o_kanban_group:last .o_kanban_record').length, 3, "still last column should contain 3 records");
+ kanban.$('.o_kanban_group:last .o_column_archive_records').click();
+ assert.ok($('.modal').length, 'a confirm modal should be displayed');
+ $('.modal-footer .btn-primary').click(); // Click on 'Ok'
+ assert.strictEqual(kanban.$('.o_kanban_group:last .o_kanban_record').length, 0, "last column should not contain any records");
+ kanban.destroy();
+ });
+
+ QUnit.test('basic grouped rendering with active field and hidden archive buttons (archivable false)', function (assert) {
+ assert.expect(2);
+
+ // add active field on partner model and make all records active
+ this.data.partner.fields.active = {string: 'Active', type: 'char', default: true};
+
+ var envIDs = [1, 2, 3, 4]; // the ids that should be in the environment during this test
+ var kanban = createView({
+ View: KanbanView,
+ model: 'partner',
+ data: this.data,
+ arch: '' +
+ '' +
+ '' +
+ '' +
+ '
' +
+ '',
+ groupBy: ['bar'],
+ });
+
+ // check archive/restore all actions in kanban header's config dropdown
+ assert.strictEqual(
+ kanban.$('.o_kanban_header:first .o_kanban_config .o_column_archive_records').length, 0,
+ "should not be able to archive all the records");
+ assert.strictEqual(
+ kanban.$('.o_kanban_header:first .o_kanban_config .o_column_unarchive_records').length, 0,
+ "should not be able to restore all the records");
+ kanban.destroy();
+ });
+
QUnit.test('pager should be hidden in grouped mode', function (assert) {
assert.expect(1);
diff --git a/doc/reference/views.rst b/doc/reference/views.rst
index 052c63a97f5..373a31b022a 100644
--- a/doc/reference/views.rst
+++ b/doc/reference/views.rst
@@ -998,6 +998,9 @@ attributes:
whether groups can be deleted via the context menu. Default: true.
``group_edit``
whether groups can be edited via the context menu. Default: true.
+``archivable``
+ whether records belonging to a column can be archived / restored if an
+ ``active`` field is defined on the model. Default: true.
``quick_create``
whether it should be possible to create records without switching to the
form view. By default, ``quick_create`` is enabled when the Kanban view is