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

QWeb to display record in Web Module ?

By
Ikss
on 3/13/13, 7:24 AM 2,218 views

Hello,

I'm trying to display records using QWeb. I have a simple structure : Client(id, name)

I want to have a view displaying

id - name
0 - smith
1 - john
2 - jack
3 - bob

So I have made a QWeb code :

<templates>
<t t-name="MyView">
    <table>
        <thead>
            <tr>
                <th t-foreach="fields_view" t-as="field">
                    <t t-esc="fields[field.attrs.name].string" />
                </th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</t>
</templates>

This code should just show the header line, but it doesn't. I get an error : "No enumerator given to foreach"

How to make the simple view I want to make with QWeb ? I'm using OE6.1

Thank You

I have the same error. Since there is many people asking this question I suspect a bug, here is the bug report : https://bugs.launchpad.net/openobject-addons/+bug/1301474

YannickB
on 4/2/14, 2:16 PM
0
YannickB
On 4/9/14, 6:20 AM

Please look at my bug ticket on Launchpad : https:// bugs.launchpad.net/openobject-addons/+bug/1301474?comments=all (It was finally not a bug).

You need to initialize the variable in _init, otherwise the foreach will not find it. Exemple :

init: function (field_manager, node) {
    this._super(field_manager, node);
    this.votes = [];
},

start: function() {
    this._super();
    this.votes = ["test", "test"]; //this.get('value');
},

Hi, I'm facing the same problem as described on the top, but your solution doesnt work for me. Please help. this is my xml:

Hello
openerp.oepetstore = function(instance, local) { var _t = instance.web._t, _lt = instance.web._lt; var QWeb = instance.web.qweb; // standard widget for our page local.HomePage = instance.Widget.extend({ className: 'oe_petstore_homepage', template: "HomePageTemplate", // load template from xml (possibility no 1 - standard) init: function(parent) { this._super(parent); this.name = "Mordecai"; this.votes = []; }, start: function() { this._super(); this.votes = ["test", "test"]; //this.get('value'); }, }); // registers our basic widget as a client action instance.web.client_actions.add('petstore.homepage', 'instance.oepetstore.HomePage'); }

Sody
on 10/15/14, 9:18 AM
0
Sody
On 10/15/14, 9:23 AM

Hi, I'm facing the same problem as described on the top, but your solution doesnt work for me. Please help. this is my xml:

 

<code>

openerp.oepetstore = function(instance, local) {
    var _t = instance.web._t,
        _lt = instance.web._lt;
    var QWeb = instance.web.qweb;

    // standard widget for our page
    local.HomePage = instance.Widget.extend({
        className: 'oe_petstore_homepage',
        template: "HomePageTemplate",                                    // load template from xml (possibility no 1 - standard)
        
        init: function(parent) {
            this._super(parent);
            this.name = "Mordecai";
            this.votes = [];
        },
        
        start: function() {
            this._super();
            this.votes = ["test", "test"]; //this.get('value');
        },
    });
        
    // registers our basic widget as a client action
    instance.web.client_actions.add('petstore.homepage', 'instance.oepetstore.HomePage');    
}

</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

0 follower(s)

Stats

Asked: 3/13/13, 7:24 AM
Seen: 2218 times
Last updated: 3/16/15, 8:10 AM