Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
2676 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Nejlepší odpověď
style="pointer-events:none;"

Add this attribute to the one2many field


Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
čvc 25
2520
2
čvc 25
7971
2
čvc 25
4406
2
čvc 25
4118
2
čvn 25
2708