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.

5

Web Services Tutorial Odoo/PHP

By
Thierry Godin
on 7/30/14, 4:16 PM 10,693 views

Hello all,

I just published a new tutorial about Web Services.

For now, it's only in french. US translation 's coming soon.

http://thierry-godin.developpez.com/openerp/openerp-xmlrpc-php-fr/

@Thierry, what would be the best way to work from Android to Odoo? Could you then best direct from Android to mySQL / PHP and then too Odoo? Or would there be a way to send from Android to Odoo instantly? Thanks for the tutorial, its great.

Yenthe
on 10/29/14, 6:34 AM

@Yenthe , Sorry mate, I don't know Android programming. I cannot help you for this :(

Thierry Godin
on 10/29/14, 4:03 PM
7

Thierry Godin

--Thierry Godin--
1516
| 8 7 8
Collegien, France
--Thierry Godin--

..

Thierry Godin
On 9/17/14, 3:57 PM

The english version of the tutorial is here :

http://thierry-godin.developpez.com/openerp/openerp-xmlrpc-php-en/

The files of the scripts can be downloaded here :

http://www.lapinmoutardepommedauphine.com/openerp/odoo_xmlrpc_php_files.zip

Good job Thierry. I wait the tutorial on odoo interface customization.

ThackerS (ts)
on 9/17/14, 4:04 PM

Thank you for sharing this Thierry! This is a goldmine of basic information to learn from.

Yenthe
on 10/13/14, 9:51 AM

Thnaks Thierry Godin ...

Ashish Singh
on 10/14/14, 2:26 AM
0
charles
On 10/13/14, 9:43 AM

Hi Godin,

I'm new to odoo and have just successfully installed odoo under Ubuntu in Oracle Virtual Box (virtual machine), which is running under windows 8. Luckily, everything is fine by using the application. 

Your tutorial is great, thanks a lot. I followed your example code (copied below) to practice. Unfortunately, the PHP program stopped at this statement "$connexion = new xmlrpc_client($server_url . "/xmlrpc/common");". And there were no error messages shown at all. 

Can you provide further help?

1. Are there any error messages to trace what happen?

2. Are there any system settings in odoo before I can use PHP XML-RPC?

Thanks a lot for your help in advance.

 

----------------------------------------------------------------------------------------------------------------------------------------------------------------

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
echo '<h2>XML-RPC AVEC OPENERP/ODOO ET PHP</h2>';

include("xmlrpc_lib/xmlrpc.inc.php");
include("xmlrpc_lib/xmlrpcs.inc.php");
$GLOBALS['xmlrpc_internalencoding']='UTF-8';

$user = 'admin';
$password = 'mY5up3rPwd';
$dbname = 'test';

$server_url = 'http://192.168.1.120:8069'; 
$connexion = new xmlrpc_client($server_url . "/xmlrpc/common");
$connexion->setSSLVerifyPeer(0);

$c_msg = new xmlrpcmsg('login');
$c_msg->addParam(new xmlrpcval($dbname, "string"));
$c_msg->addParam(new xmlrpcval($user, "string"));
$c_msg->addParam(new xmlrpcval($password, "string"));
$c_response = $connexion->send($c_msg);

if ($c_response->errno != 0){
    echo  '<p>error : ' . $c_response->faultString() . '</p>';
}
else{
    
    $uid = $c_response->value()->scalarval();

    $val = array ( 
        "name"    => new xmlrpcval("Godin Thierry", "string"),
        "street"  => new xmlrpcval("Au fond à gauche", "string"),
        "city"    => new xmlrpcval("Marne la Vallée", "string"),
        "zip"     => new xmlrpcval("77000", "string"),
        "website" => new xmlrpcval("http://www.lapinmoutardepommedauphine.com", "string"),
        "lang"    => new xmlrpcval("fr_FR", "string"),
        "tz"      => new xmlrpcval("Europe/Paris", "string"),
        ); 
    
    $client = new xmlrpc_client($server_url . "/xmlrpc/object");
    $client->setSSLVerifyPeer(0);

    $msg = new xmlrpcmsg('execute'); 
    $msg->addParam(new xmlrpcval($dbname, "string")); 
    $msg->addParam(new xmlrpcval($uid, "int")); 
    $msg->addParam(new xmlrpcval($password, "string")); 
    $msg->addParam(new xmlrpcval("res.partner", "string")); 
    $msg->addParam(new xmlrpcval("create", "string")); 
    $msg->addParam(new xmlrpcval($val, "struct")); 
    $response = $client->send($msg);
    
    echo 'Partner created - partner_id = ' . $response->value()->scalarval();
}
?>

Hi Charles, You have to set the proper IP address of your own server, you have to set the proper dbname you use and your own credentials (username + password). Also, ensure you have copied the xmlrpc lib in the right path.

Thierry Godin
on 10/13/14, 10:32 AM

Hi Thierry, Thank you very much for your reply. I'm sorry that I didn't make it clear. I did set the IP address, dbname, login and password correctly. For the xmlrpc lib, I copy it to a folder by following your comments in your tutorial. Please my code extract below. By the way, my odoo version is 8. Are there any settings in the odoo server side? echo '

XML-RPC AVEC OPENERP/ODOO ET PHP

'; include("xmlrpc/lib/xmlrpc.inc.php"); include("xmlrpc/lib/xmlrpcs.inc.php"); $GLOBALS['xmlrpc_internalencoding']='UTF-8'; $user = 'admin'; $password = 'password'; $dbname = 'mydb'; $server_url = 'http://192.168.56.101:8069';
charles
on 10/14/14, 9:05 AM

Hi Thierry, I've found a problem. In my version of xmlrpc, the file names of xmlrpc.inc and xmlrpcs.inc are without .php. In other words, the file names are xmlrpc.inc and xmlrpcs.inc only. In addition, there is typo in the program. It should be $c_response (not $response) of the following statement : echo 'Partner created - partner_id = ' . $response->value()->scalarval(); Although the program can be run successfully now, I can't find the record in odoo. Will check again tomorrow. Good night.

charles
on 10/15/14, 11:21 AM

Your 're right Charles, right typo is $c_response. Thanks for the info. About adding .php to .inc file is a security stuff to avoid diplaying inc file in browser.

Thierry Godin
on 10/15/14, 2:15 PM

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

5 follower(s)

Stats

Asked: 7/30/14, 4:16 PM
Seen: 10693 times
Last updated: 5/3/16, 2:44 AM