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

My JS function doesn't return array value?

By
Jo
on 9/23/15, 4:50 AM 599 views

Hi all,

I'm trying show a partners in dropdown box at Warehouse->All operations->Click to launch the barcode interface.

my code is:

in addons\stock\static\src\xml\picking.xml

<div class="col-md-3 col-sm-4 col-xs-6">

    <h3><strong>

        <select class="form-control">

            <t t-foreach="widget.get_partners()" t-as="partner">

                <option value="partne.id"><t t-esc="partner.name"/></option>

            </t>

        </select>

    </strong>

    </h3>

</div>


in \addons\stock\static\src\js\widget.js

get_partners: function(){

    var self = this;

    var partners = [];

    var model = new instance.web.Model('res.partner');

    model.query(['id', 'name']).filter([['customer', '=', 'True']]).limit(1000).all().done(function(partners){

        self.partners = partners;

        console.log(partners); // returns excepted values

    });

    return partners; // but here doesn't return any value

},


I mentioned in my code by comments, what i need.


please give me suggestions.

Thanks in advance

jyothimani,
at place of "return partners", try "return self.partners"...

Pawan
on 9/23/15, 6:09 AM

I tried it. but not returns any value.

Jo
on 9/23/15, 6:21 AM
0
Ayaz Mansuri
On 3/11/16, 6:30 AM

I've posted answer here: https://www.odoo.com/nl_NL/forum/help-1/question/how-to-read-the-res-partner-ids-in-javascript-91165#answer-98549

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: 9/23/15, 4:50 AM
Seen: 599 times
Last updated: 3/11/16, 6:30 AM