diff --git a/addons/base_import/static/src/js/import_buttons.js b/addons/base_import/static/src/js/import_buttons.js
index f6d246a8586..89baedc8113 100644
--- a/addons/base_import/static/src/js/import_buttons.js
+++ b/addons/base_import/static/src/js/import_buttons.js
@@ -13,11 +13,13 @@ var ImportViewMixin = {
/**
* @override
* @param {Object} params
- * @param {boolean} [params.import_enabled=true] determine if the import
- * button is visible (in the control panel)
+ * @param {boolean} [params.import_enabled=true] set to false to disable
+ * the Import feature (no 'Import' button in the control panel). Can also
+ * be disabled with 'import' attrs set to '0' in the arch.
*/
init: function (viewInfo, params) {
- var importEnabled = 'import_enabled' in params ? params.import_enabled : true;
+ var importEnabled = !!JSON.parse(this.arch.attrs.import || '1') &&
+ ('import_enabled' in params ? params.import_enabled : true);
this.controllerParams.importEnabled = importEnabled && !config.device.isMobile;
},
};
diff --git a/addons/base_import/static/tests/import_buttons_tests.js b/addons/base_import/static/tests/import_buttons_tests.js
index 40bd162dd2f..fdb0e2a816e 100644
--- a/addons/base_import/static/tests/import_buttons_tests.js
+++ b/addons/base_import/static/tests/import_buttons_tests.js
@@ -106,4 +106,35 @@ QUnit.test('kanban without import button', async function(assert) {
kanban.destroy();
});
+QUnit.test('import attrs in list views', async function (assert) {
+ assert.expect(1);
+
+ var list = await createView({
+ View: ListView,
+ model: 'foo',
+ data: this.data,
+ arch: '',
+ });
+
+ assert.containsNone(list.$buttons, '.o_button_import');
+ list.destroy();
+});
+
+QUnit.test('import attrs in kanban views', async function (assert) {
+ assert.expect(1);
+
+ var kanban = await createView({
+ View: KanbanView,
+ model: 'foo',
+ data: this.data,
+ arch: '' +
+ '' +
+ '
' +
+ '' +
+ '',
+ });
+
+ assert.containsNone(kanban.$buttons, '.o_button_import');
+ kanban.destroy();
+});
});
diff --git a/doc/reference/views.rst b/doc/reference/views.rst
index 746c5e48b32..68d024e47db 100644
--- a/doc/reference/views.rst
+++ b/doc/reference/views.rst
@@ -216,7 +216,7 @@ root can have the following attributes:
(``font-style: italic``), or any `bootstrap contextual color
`_ (``danger``,
``info``, ``muted``, ``primary``, ``success`` or ``warning``).
-``create``, ``edit``, ``delete``, ``duplicate``
+``create``, ``edit``, ``delete``, ``duplicate``, ``import``
allows *dis*\ abling the corresponding action in the view by setting the
corresponding attribute to ``false``
``limit``