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.

1

Use data in a web widget ?

By
Ikss
on 3/13/13, 8:18 AM 1,931 views

Hi there,

I have made a widget that I can use in my module. It displays a cube in 3D using WebGL. The cube is currently white, but I want to color it with a color stocked in the OpenERP 6.1 data base.

I have that : Color(red,blue, green)

I wanted to know how to access that data to color my cube ? Maybe a javascript thing "model.get() etc" or a way to read the display of the module with getElementByID() ?

0
Ikss
On 3/18/13, 11:41 AM

I finally find how to display a record. Here is a simple function Javascript :

    openerp.test = function(openerp) {
      openerp.web.form.widgets.add('myWidget','openerp.web.form.myWidget');

    openerp.web.form.myWidget = openerp.web.form.Field.extend(
    {    

 start: function() {     
       this.Read());

    },

           Read: function() {
                console.log('start to read');
                var self = this.view;
                this.rpc('/web/dataset/search_read', {
                    model: this.view.model,
                    fields: fields || false,
                    domain: this.view.domain,
                    context: this.view.context,
                    offset: 0,
                    limit: false
                }).pipe(function (result) {
                    self.ids = result.ids;
                    self._length = result.length;          
                    console.log(result);            
                    return result.records; // Records is the table of the module
                }); 
                console.log('finished to read');
            },    

    }

Then you can access the data :

console.log(result.records); //display all the records
console.log(result.records[id]); //display all column of record #id
console.log(result.records[id]['column']); //display column 'column' of record #id

Then you can just save it in a variable and use it with JQuery in your QWeb file.

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

1 follower(s)

Stats

Asked: 3/13/13, 8:18 AM
Seen: 1931 times
Last updated: 3/16/15, 8:10 AM