diff --git a/addons/web/static/src/js/views/list/list_renderer.js b/addons/web/static/src/js/views/list/list_renderer.js
index 31300ae53d1..8138b225528 100644
--- a/addons/web/static/src/js/views/list/list_renderer.js
+++ b/addons/web/static/src/js/views/list/list_renderer.js
@@ -745,6 +745,14 @@ var ListRenderer = BasicRenderer.extend({
var isNodeSorted = order[0] && order[0].name === name;
var field = this.state.fields[name];
var $th = $('
');
+ if (node.attrs.class) {
+ if (node.attrs.class.indexOf('oe_edit_only') !== -1) {
+ $th.addClass('oe_edit_only');
+ }
+ if (node.attrs.class.indexOf('oe_read_only') !== -1) {
+ $th.addClass('oe_read_only');
+ }
+ }
if (!field) {
return $th;
}
diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js
index 765beb7ed08..1c0c9ae9485 100644
--- a/addons/web/static/tests/views/form_tests.js
+++ b/addons/web/static/tests/views/form_tests.js
@@ -4627,6 +4627,83 @@ QUnit.module('Views', {
form.destroy();
});
+ QUnit.test('oe_read_only className is handled in list views', async function (assert) {
+ assert.expect(5);
+
+ var form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '',
+ res_id: 1,
+ });
+
+ assert.hasClass(form.$('.o_form_view'), 'o_form_readonly',
+ 'form should be in readonly mode');
+ assert.isVisible(form.$('.o_field_one2many .o_list_view thead th[data-name="display_name"]'),
+ 'display_name cell should be visible in readonly mode');
+
+ await testUtils.form.clickEdit(form);
+ assert.hasClass(form.$('.o_form_view'), 'o_form_editable',
+ 'form should be in edit mode');
+ assert.isNotVisible(form.$('.o_field_one2many .o_list_view thead th[data-name="display_name"]'),
+ 'display_name cell should not be visible in edit mode');
+
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ assert.hasClass(form.$('.o_form_view .o_list_view tbody tr:first input[name="display_name"]'),
+ 'oe_read_only', 'display_name input should have oe_read_only class');
+
+ form.destroy();
+ });
+
+ QUnit.test('oe_edit_only className is handled in list views', async function (assert) {
+ assert.expect(5);
+ var form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '',
+ res_id: 1,
+ });
+
+ assert.hasClass(form.$('.o_form_view'), 'o_form_readonly',
+ 'form should be in readonly mode');
+ assert.isNotVisible(form.$('.o_field_one2many .o_list_view thead th[data-name="display_name"]'),
+ 'display_name cell should not be visible in readonly mode');
+
+ await testUtils.form.clickEdit(form);
+ assert.hasClass(form.$('.o_form_view'), 'o_form_editable',
+ 'form should be in edit mode');
+ assert.isVisible(form.$('.o_field_one2many .o_list_view thead th[data-name="display_name"]'),
+ 'display_name cell should be visible in edit mode');
+
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ assert.hasClass(form.$('.o_form_view .o_list_view tbody tr:first input[name="display_name"]'),
+ 'oe_edit_only', 'display_name input should have oe_edit_only class');
+
+ form.destroy();
+ });
+
QUnit.test('*_view_ref in context are passed correctly', async function (assert) {
var done = assert.async();
assert.expect(3);
|