Odoo 10 / Js - Problems with 'start' function in Widget extension

779 views Asked by At

I am using Odoo 10.

I'm having a problem with a Widget extension, as the title says.

I would query a model recordset to display each record in a template, but I can not execute the block inside the 'function start'.

I tried to put a 'console.log' inside the 'function()' block but it is not fired.

Does anybody know why?

My fuction code:

openerp.crm_broadband = function(instance, local) {
'use strict'

var _t = instance.web._t,
    _lt = instance.web._lt;
var QWeb = instance.web.qweb;


local.SiteList = instance.web.Widget.extend({
    template: 'SiteList',
    start: function() {
        var self = this
        return new instance.web.Model('broadband.site')
            .query(['name'])
            .filter([['site_type', 'in', ['backbone_master', 'backbone_slave', 'backbone_hop']]])
            .all()
            .then(function(result) {
                result.each(function(item) {
                    self.$el.append(QWeb.render('SiteElement', {item: item}))
                })
        })
    }
})
instance.web.client_actions.add('widget_site_list', 'instance.crm_broadband.SiteList')

}

QWeb

<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">

    <t t-extend="sales_team.SalesDashboard">
        <t t-jquery="div.o_sales_dashboard" t-operation="after">
            <div class="o_board_div">
                <div class="widget_site_list">
                    <t t-call="SiteList"/>
                </div>
            </div>
        </t>
    </t>

    <t t-name="SiteList">
        <div>
        </div>
    </t>

    <t t-name="SiteElement">
        <div>
            <p><t t-esc="item.name"/></p>
        </div>
    </t>

</templates>
0

There are 0 answers