Skip to Content
Menu
This question has been flagged
2502 Views

Hello,


Description:


I have one one2many field with many2many_tags widget. After clicking on the button I want to update the one2many field. I am able to update one2manyfield. But if after a click on the button I manually refresh the page then my one2many the field is updated in the form view.


Question:


How to update one2many field without manually refreshing page.


To update field I have created python function and this function is a call from js file


Python file:


```

@api.multi

def testquestion(self,vals):

id1 = vals['id']

update_data = {}


update_data = {

'question': vals['question'],

#'type': vals['type'],

'constr_mandatory': self.constr_mandatory,

'constr_error_msg': self.constr_error_msg,

}

exiting_data = self.env['survey.question'].search([('id','=',id1)]).write(update_data)

return exiting_data #return True

```

js file:

```

var formController = FormController.include({


_onButtonClicked: function (event) {

var self = this;

if(event.data.attrs.id === "button_update_question"){

if (this.mode != 'edit')

return undefined;


var id = $('.id_question_update').val();

var question = $('.question_class').val();

var type = $('.select_question').val();

this._rpc({

model: 'survey.survey',

method: 'testquestion',

args: [{

id: id,

question: question,

//type,

}],

}).then(function (result) {

});

}

this._super(event);

},

});

```

Thanks in advance


Avatar
Discard
Related Posts Replies Views Activity
2
Dec 23
11999
0
Oct 23
33
3
Oct 23
787
1
Oct 23
569
1
Aug 23
979