Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
10842 มุมมอง

I have created a custom rating widget in openerp using Rateit.

But the widget is always editable, How can i make it editable only when i click 'Edit' button and How do i know it is in readonly mode?

xml

<field name="rating" widget="rating"/>

js

instance.my_module.Rating = instance.web.form.FieldChar.extend({
        template : "rating",
        init: function(field_manager, node){
            this._super.apply(this, arguments);

        },

        start: function() {

            var self = this;

            $('#rateit').rateit({
                value: 0,
                resetable: false
            });
        },
    });

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Finally i got it working, here is my code

start: function() {

            var self = this;
            this.field_manager.has_been_loaded.done(function() {
                $('#rateit').rateit({
                    value: 0,
                    resetable: false
                });
                self.field_manager.on("change:actual_mode", self, self.check_actual_mode);
                self.check_actual_mode();
            });

 },
 
 check_actual_mode: function(source, options) {
    var self = this;
    if(self.field_manager.get("actual_mode")=='view'){
        $('#rateit').rateit('readonly',true);
    }
    else {
        $('#rateit').rateit('readonly',false);
    }
}

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

please Does anyone has the solution of this?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Sajad,

I have created a widget but with out clicking edit button i am able to give input to it. I tried to use your code but it tells me rateit method not found. What to give inside rateit ?.

Please help me i am struck 

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.พ. 24
1118
0
เม.ย. 23
4755
1
พ.ค. 19
4019
0
มี.ค. 15
4509
0
ธ.ค. 24
856