Как загрузить данные с помощью функции JavaScript в odoo v10?

Я пытаюсь загрузить данные из модуля в odoo с помощью функции Javascript.

Контроллер.основной:

        @http.route(['/datatables/model/get_partners'], type='json', auth="user", website=True)
        def get_partners(self, offset=0, page_size=500, count_only=False):
            data_obj = request.env['res.partner'].sudo()
            if count_only:
                return [{'count': data_obj.search([('id', '>', 0)], count=True)}]
            else:
                data_ids = data_obj.search([('id', '>', 0)], offset=offset, limit=page_size)
                if not data_ids:
                    return []
                data_tb = []
                for data in data_ids:
                    data_tb.append([
                        data.name,
                        data.title if data.title else '',
                        data.lang if data.lang else '',
                        1 if data.supplier else 0,
                        1 if data.employee else 0,
                    ])
                logger.debug('Partners current offset: %s', offset)
                return data_tb

Функция Javascript:

    odoo.define('website_datatables.search', function (require) {
        "use strict";
    var ajax = require('web.ajax');
    var core = require('web.core');
    var website = require('website.website');

    var QWeb = core.qweb;

    $('#partners_data tfoot th').each( function () {
        if ($(this).index() > 3) {
            $(this).html( ' ');
        } else {
            $(this).html( '<input type="text" placeholder="?.?." />');
        }

    });
    var table = $('#partners_data').DataTable();
    table.clear();
    var max_return = 500;
    ajax.jsonRpc('/datatables/model/get_partners', 'call',
        { 'count_only' : 1 } )
    .then(function(data) {
            _.each(data, function(record) {
                console.log('record: '+record['count']);
                var nof_rows = record['count'];
                while (true) {
                    ajax.jsonRpc('/datatables/model/get_partners', 'call',
                        { 'offset' : offset, 'page_size' : page_size } )
                        .then( function(data) {
                            if (data) {
                                table.rows.add(data).draw()
                            }
                        });
                    if (nof_rows == 0) {
                        break;
                    }
                    offset += page_size;
                    if (nof_rows > page_size) {
                        nof_rows -= page_size;
                    } else {
                        page_size = nof_rows;
                        nof_rows = 0;
                    }
                    console.log('nof_rows: '+nof_rows);
                }
            });
    });

    });

XML-шаблон таблицы:

    <table id="partners_data" class="display cell-border">
        <thead>
            <tr>
                <th>Name</th>
                <th>Title</th>
                <th>Language</th>
                <th>Supplier</th>
                <th>Employee</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>Name</th>
                <th>Title</th>
                <th>Language</th>
                <th>Supplier</th>
                <th>Employee</th>
            </tr>
        </tfoot>
        <tbody>
        </tbody>
    </table>

но я не получаю никаких данных от этого. Нижний колонтитул меняется, но таблица остается пустой.


person Maysam AL    schedule 08.02.2017    source источник
comment
У меня также открыт аналогичный вопрос: stackoverflow.com/questions /42227474/   -  person user568021    schedule 14.02.2017