跳至内容
菜单
此问题已终结
2 回复
2702 查看

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











形象
丢弃
最佳答案

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

形象
丢弃
最佳答案
style="pointer-events:none;"

Add this attribute to the one2many field


形象
丢弃
相关帖文 回复 查看 活动
1
8月 25
1955
1
7月 25
2525
2
7月 25
7973
2
7月 25
4409
2
7月 25
4130