I have a function that return something like [object object] no my value that I wanted , I do almost every thing to get the value but no hope.
When I try to show that object using toSource() I got something like that.
({state:(function (){return state;}), always:(function (){deferred.done(arguments).fail(arguments);return this;}), then:(function (){var fns=arguments;return jQuery.Deferred(function(newDefer){jQuery.each(tuples,function(i,tuple){var action=tuple[0],fn=fns[i];deferred[tuple[1]](jQuery.isFunction(fn)?function(){var returned=fn.apply(this,arguments);if(returned&&jQuery.isFunction(returned.promise)){returned.promise().done(newDefer.resolve).fail(newDefer.reject).progress(newDefer.notify);}else{newDefer[action+"With"](this===deferred?newDefer:this,[returned]);}}:newDefer[action]);});fns=null;}).promise();}), promise:(function (obj){return obj!=null?jQuery.extend(obj,promise):promise;}), pipe:(function (){var fns=arguments;return jQuery.Deferred(function(newDefer){jQuery.each(tuples,function(i,tuple){var action=tuple[0],fn=fns[i];deferred[tuple[1]](jQuery.isFunction(fn)?function(){var returned=fn.apply(this,arguments);if(returned&&jQuery.isFunction(returned.promise)){returned.promise().done(newDefer.resolve).fail(newDefer.reject).progress(newDefer.notify);}else{newDefer[action+"With"](this===deferred?newDefer:this,[returned]);}}:newDefer[action]);});fns=null;}).promise();}), done:(function (){if(list){var start=list.length;(function add(args){jQuery.each(args,function(_,arg){var type=jQuery.type(arg);if(type==="function"){if(!options.unique||!self.has(arg)){list.push(arg);}}else if(arg&&arg.length&&type!=="string"){add(arg);}});})(arguments);if(firing){firingLength=list.length;}else if(memory){firingStart=start;fire(memory);}}
return this;}), fail:(function (){if(list){var start=list.length;(function add(args){jQuery.each(args,function(_,arg){var type=jQuery.type(arg);if(type==="function"){if(!options.unique||!self.has(arg)){list.push(arg);}}else if(arg&&arg.length&&type!=="string"){add(arg);}});})(arguments);if(firing){firingLength=list.length;}else if(memory){firingStart=start;fire(memory);}}
return this;}), progress:(function (){if(list){var start=list.length;(function add(args){jQuery.each(args,function(_,arg){var type=jQuery.type(arg);if(type==="function"){if(!options.unique||!self.has(arg)){list.push(arg);}}else if(arg&&arg.length&&type!=="string"){add(arg);}});})(arguments);if(firing){firingLength=list.length;}else if(memory){firingStart=start;fire(memory);}}
return this;})})
Could any one explain me? And I know my function is Asynchronous.
How could solve this problem ?
Here is my code:
  module.Order = Backbone.Model.extend({
        initialize: function (attributes) {
            Backbone.Model.prototype.initialize.apply(this, arguments);
            this.pos = attributes.pos;
            this.sequence_number = this.pos.pos_session.sequence_number++;
            debugger;
            var odoo = []
            var call = this
            this.uid = this.generateUniqueId();
            this.pro = this.get_the_other_main().done(
                function (result) {
                }).always(function (result) {
                    odoo.push(result)
                    call.set({
                creationDate: new Date(),
                orderLines: new module.OrderlineCollection(),
                paymentLines: new module.PaymentlineCollection(),
                name: _t("Order ") + this.uid,
                client: null,
                sales_person: null,
                sales_person_name: null,
                new_id: odoo[0]
            })});
            alert(odoo[0])//// Must be adddddedd
            this.selected_orderline = undefined;
            this.selected_paymentline = undefined;
            this.screen_data = {};  // see ScreenSelector
            this.receipt_type = 'receipt';  // 'receipt' || 'invoice'
            this.temporary = attributes.temporary || false;
            return this;
        },
get_the_other_main: function () {
            var dfd = new jQuery.Deferred();
            new instance.web.Model("pos.order").call('get_the_product', []).done(
                function (results) {
                    var result = results.toString().split(',');
                    var stringsl = result[1];
                    var thenum = stringsl.replace(/^\D+/g, '');
                    var sasa = parseInt(thenum, 10) + 1
                    var zika = ('00' + sasa).slice(-4)
                    var the_str = result[1].slice(0, -4).toString();
                    var new_seq_sasa = the_str + zika
                    dfd.resolve(new_seq_sasa);
                }).always(function(results) {
                    var result = results.toString().split(',');
                    var stringsl = result[1];
                    var thenum = stringsl.replace(/^\D+/g, '');
                    var sasa = parseInt(thenum, 10) + 1
                    var zika = ('00' + sasa).slice(-4)
                    var the_str = result[1].slice(0, -4).toString();
                    var new_seq_sasa = the_str + zika
                    dfd.resolve(new_seq_sasa);
                }).always(function(results) {
                    var result = results.toString().split(',');
                    var stringsl = result[1];
                    var thenum = stringsl.replace(/^\D+/g, '');
                    var sasa = parseInt(thenum, 10) + 1
                    var zika = ('00' + sasa).slice(-4)
                    var the_str = result[1].slice(0, -4).toString();
                    var new_seq_sasa = the_str + zika
                    dfd.resolve(new_seq_sasa);
                });
            alert('')////If i remove that it will return undefind for this.pos
            return dfd
 
    