When I try to make a Javascript call using xmlrpc with JQuery, I get this error

-1
  

jquery-3.2.1.js: 3860 jQuery.Deferred exception: True is not defined   ReferenceError: True is not defined        at Object. (file: /// C: /Users/user/Downloads/odoo-js/funciones.js: 38: 84)        at mightThrow (file: /// C: /Users/user/Downloads/odoo-js/jquery-3.2.1.js: 3583: 29)        at process (file: /// C: /Users/user/Downloads/odoo-js/jquery-3.2.1.js: 3651: 12)   undefined jQuery.Deferred.exceptionHook @ jquery-3.2.1.js: 3860

Hello,

This error, I get when I make a second call using xmlrpc against Odoo. In the first call with xmlrpc to the login method, I get the user's uid. Once I get the uid, I make a second call with xmlrpc to the method execute_kw to get the clients of said uid (table res.partner) and in that second call is when the jQuery fails

function autenticar(){  
    var uid;    
    $.when(
        $.xmlrpc({  
            url: 'http://192.168.1.50:8069/xmlrpc/2/common',
            methodName: 'login',
            crossDomain: true,
            params: ['database', 'admin', 'admin'],
            success: function(response, status, jqXHR) {uid = response;},
            error: function(jqXHR, status, error) { alert('Error : ' + error.debug ) }
            })
    ).then(function( data, textStatus, jqXHR ) {        
        $.xmlrpc({  
            url: 'http://192.168.1.50:8069/xmlrpc/2/object',
            methodName: 'execute_kw',
            crossDomain: true,
            params: ['database',uid,'admin','res.partner', 'search',[[['is_company', '=', True], ['customer', '=', True]]]],
            success: function(response, status, jqXHR) {alert('segunda_llamada');alert(response);},
            error: function(jqXHR, status, error) { alert('Error : ' + error ) }
            })
    });
}

    
asked by Santiago Carbonell 27.10.2017 в 13:43
source

1 answer

0

Good!

This is a shot in the air, but it seems to me that the error you're in lies in the True that you send as a parameter. In JavaScript, it is written without a capital letter, in lowercase: true .

So on the line:

    params: ['database',uid,'admin','res.partner', 'search',[[['is_company', '=', True], ['customer', '=', True]]]],

You should replace True with true :

    params: ['database',uid,'admin','res.partner', 'search',[[['is_company', '=', true], ['customer', '=', true]]]],

Unless the request is not requesting a boolean directly, it does not want the text 'True' in which case it would be:

    params: ['database',uid,'admin','res.partner', 'search',[[['is_company', '=', 'True'], ['customer', '=', 'True']]]],
    
answered by 30.10.2017 в 11:21