Skip to Content
Menú
This question has been flagged
2 Respostes
2697 Vistes

I am trying to prevent the tree view from opening a popup when clicked.

The tree view is inside a form and "editable=bottom" does not work.


So I am trying to extend this with javascript:


I took this from here

// https://github.com/odoo/odoo/blob/fa58938b3e2477f0db22cc31d4f5e6b5024f478b/addons/web/static/src/legacy/js/views/list/list_renderer.js#L1430


The popup doesn't up anymore. But this seems to apply to all views.

I just want this to be applied to a specific form view in my module.


Thank you for any help











Avatar
Descartar
Best Answer

Hi,
You can extend the ListRenderer and add ev.preventDefault() in the click function. Then, add the new ListRenderer to the registry and include this widget in your field. This solution will resolve the issue.

odoo.define('my_module.list_renderer', function(require) {
"uses strict";
var FieldOne2Many = require('web.relational_fields').FieldOne2Many;
var fieldRegistry = require('web.field_registry');
var ListRenderer = require('web.ListRenderer');
var listRenderer = ListRenderer.extend({
events: _.extend({}, ListRenderer.events, {
'click .o_data_row': function(ev) {
ev.preventDefault();
},
})
});

var listFieldOne2Many = FieldOne2Many.extend({

_getRenderer: function() {
if (this.view.arch.tag === 'tree') {
return listRenderer;
}
return this._super.apply(this, arguments);
},
});
fieldRegistry.add('list_one2many', listFieldOne2Many);
return listRenderer;
});

<field name="one2many_field_name" widget="list_one2many">



Hope it helps

Avatar
Descartar
Best Answer
style="pointer-events:none;"

Add this attribute to the one2many field


Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
d’ag. 25
1927
1
de jul. 25
2524
2
de jul. 25
7972
2
de jul. 25
4409
2
de jul. 25
4128