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

Display a record ?

By
Ikss
on 3/13/13, 12:25 PM 1,045 views

Hello

I am developing a web module in OpenERP 6.1 I want to display this record, so I would be able to use it with JQuery.

How can I do that simple thing ?

2

Daniel Reis

--Daniel Reis--
3436
| 6 7 9
Lisbon, Portugal
--Daniel Reis--

Author of the "Odoo Development Essentials" book.

Applications Manager at Securitas Portugal

Github: https://github.com/dreispt

Twitter; @reis_pt


Daniel Reis
On 3/13/13, 2:57 PM

You can refer to the step by step guide for OpenERP custom web development in the official docs.

1
Ikss
On 3/18/13, 11:39 AM

I finally find how to display a record, and that is NOT in the OpenERP documentation ! 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

0 follower(s)

Stats

Asked: 3/13/13, 12:25 PM
Seen: 1045 times
Last updated: 3/16/15, 8:10 AM