Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
2681 Vizualizări

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











Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Cel mai bun răspuns
style="pointer-events:none;"

Add this attribute to the one2many field


Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
iul. 25
2521
2
iul. 25
7971
2
iul. 25
4406
2
iul. 25
4121
2
iun. 25
2708