Skip to Content
Menu
This question has been flagged
2 Replies
1348 Views

Hi all,

I want to disable select and input fields if they contain any data.
how can I achieve this in Odoo 17?



Avatar
Discard
Best Answer

using js file you can achieve this    

               
odoo.define('my_module.disable_fields', function (require) {

                        "use strict";

                        var FormController = require('web.FormController');

                        FormController.include({

                            renderButtons: function () {

                                this._super.apply(this, arguments);

                                var self = this;

                                var $name_field = this.$el.find('input[name="name"]');

                                var $select_field = this.$el.find('select[name="select_field"]');


                                if ($name_field.val()) {

                                    $name_field.prop('disabled', true);

                                }

                                if ($select_field.val()) {

                                    $select_field.prop('disabled', true);

                                }

                            },

                        });

                    });

             

hope this gone help you

Avatar
Discard
Best Answer

Hello Vikas Maharana


Hope you are doing well.


- This is example of code .


/ @odoo-module /

import publicWidget from "@web/legacy/js/public/public_widget";



publicWidget.registry.EquipmentCall = publicWidget.Widget.extend({

    events: {

        'keyup .oe_vm_ddlgnc_comment': '_keyUpgncomment',


       init() {

        this._super(...arguments);

        this.rpc = this.bindService("rpc");

    },

    var publicWidget = require('web.public.widget');

      _keyUpgncomment: function(ev) {

           if ($('.oe_vm_ddlgnc_comment').val){

               $(".oe_vm_ddlgnc_comment").attr("disabled", true);

           } else {

               $(".oe_vm_ddlgnc_score_slct").attr("disabled", true);

           }

    },


I Hope this information proves helpful to you.

Thanks & Regards,

Email:   odoo@aktivsoftware.com           

Skype: kalpeshmaheshwari

Avatar
Discard
Related Posts Replies Views Activity
1
Jul 24
27
0
Jul 24
1173
0
Jun 24
990
1
May 24
1234
1
Sep 23
1724