[IMP] web: list: import attrs
The 'import' attrs is valid according to the rng definition of the list view. It is used in a few views in Odoo. However, it didn't actually work (in most cases, it worked by chance because it is set to "0" in addition to create="0", and create="0" already disables the import feature). With this ref, the 'import' attrs is taken into account and we can now disable the import feature even if the create one is enabled. Moreover, it is now documented.
This commit is contained in:
@@ -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;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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: '<tree import="0"><field name="foo"/></tree>',
|
||||
});
|
||||
|
||||
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: '<kanban import="0">' +
|
||||
'<templates><t t-name="kanban-box">' +
|
||||
'<div><field name="foo"/></div>' +
|
||||
'</t></templates>' +
|
||||
'</kanban>',
|
||||
});
|
||||
|
||||
assert.containsNone(kanban.$buttons, '.o_button_import');
|
||||
kanban.destroy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -216,7 +216,7 @@ root can have the following attributes:
|
||||
(``font-style: italic``), or any `bootstrap contextual color
|
||||
<https://getbootstrap.com/docs/3.3/components/#available-variations>`_ (``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``
|
||||
|
||||
Reference in New Issue
Block a user