Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Backend javascript - how transfer current id of form object to script?

By
zbik
on 6/19/15, 2:20 PM 1,957 views

Question related to my previous

I want to get the id (and model) of the form in the backend javascript function (event click). How to get this?

2

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 6/20/15, 5:51 AM

Full example how to get, in javascript, field_values array, model, ids and id in backend form:

inherited XML:

<div id="target">Click here</div> 

Javascript:

openerp.my_module = function(instance) {

instance.web.FormView = instance.web.FormView.extend({
events: {
'click #target button': 'button_clicked',
},

button_clicked: function(ev) {
ev.preventDefault();
ev.stopPropagation();

var field_values = this.get_fields_values();
var ids = this.get_selected_ids();
var id = field_values['id']
var model = this.model

openerp.jsonRpc('/my_module/example/, 'call', { model: model, ids: ids, id: id}).then(function (data) {
...my code...
});

},
});

}

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 6/19/15, 2:20 PM
Seen: 1957 times
Last updated: 6/20/15, 8:48 AM