تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
2690 أدوات العرض

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
يوليو 25
2521
2
يوليو 25
7972
2
يوليو 25
4406
2
يوليو 25
4124
2
يونيو 25
2708