How to use PHP7 Ripcord library to get Odoo data?

后端 未结 1 1766
遇见更好的自我
遇见更好的自我 2020-12-21 13:40

I am trying to get some data from Odoo through XMLRPC, and I am working with PHP and its Ripcord library (recommended on https://www.odoo.com/documentation/8.0/api_integrati

相关标签:
1条回答
  • 2020-12-21 14:06

    Ok, I had not error log enabled in php.ini, so I always get nothing. If I had enabled it earlier, I would have seen that the error was that I was trying to print a kind of value I cannot print, so the problem was in the die command.

    Now, it is working perfectly with this code:

    $url = 'http://localhost:30080';
    $db = 'db_v80_test_01';
    $username = 'admin';
    $password = 'adminpwd';
    
    require_once('ripcord/ripcord.php');
    
    $common = ripcord::client($url.'/xmlrpc/2/common');
    $uid = $common->authenticate($db, $username, $password, array());
    $models = ripcord::client("$url/xmlrpc/2/object");
    $partners = $models->execute_kw(
        $db,
        $uid,
        $password,
        'res.partner',
        'search',
        array(
            array(
                array('is_company', '=', true),
                array('customer', '=', true)
            )
        )
    );
    
    echo('RESULT:<br/>');
    foreach ($partners as $partner) {
        echo $partner.'<br/>';
    }
    
    0 讨论(0)
提交回复
热议问题