İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
1293 Görünümler

I have a one2many field and I think it is odoo's default behavior that when you click on an input that belongs to one2many field, contents of the input (type='text') will be auto-selected (highlighted). It is a little tiring that you have to click twice/thrice just to remove highlight and go to the desired character position, removing auto-select will give user the freedom to select desired character position by just one click on the input.

Anyone knows how to stop this behavior? Thanks!

Avatar
Vazgeç
En İyi Yanıt

The behavior you’re describing is indeed a default behavior in Odoo for 'one2many' fields. However, there isn’t a straightforward configuration option to disable this auto-selection feature.


To change this behavior, you would likely need to modify the Odoo JavaScript code that handles this auto-selection. This would involve extending the relevant widget in the Odoo JavaScript framework to override the default behavior.


Here’s a basic example of how you might do this:


odoo.define('your_module.field', function (require) {

    "use strict";


    var fieldRegistry = require('web.field_registry');

    var FieldText = require('web.basic_fields').FieldText;


    var FieldTextNoAutoselect = FieldText.extend({

        events: _.extend({}, FieldText.prototype.events, {

            'click': function (event) {

                event.stopPropagation();

            },

        }),

    });


    fieldRegistry.add('text_no_autoselect', FieldTextNoAutoselect);


    return FieldTextNoAutoselect;

});


In this example, a new field type 'text_no_autoselect' is created by extending the 'FieldText' widget. The click event is overridden to stop the propagation of the event, which should prevent the auto-selection.


Hope this helps.


Best regards,
Maciej Burzymowski

 

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Tem 23
2680
1
Tem 25
2432
2
Tem 25
7898
2
Tem 25
4304
2
Tem 25
4041