Skip to content

Latest commit

 

History

History
80 lines (54 loc) · 2.27 KB

README.rst

File metadata and controls

80 lines (54 loc) · 2.27 KB

php-oe-json

Latest Stable Version Total Downloads Latest Unstable Version License

Modest PHP class to manage OpenERP Json query.

Code maturity

Early working alpha. Comments welcome. Although it was tested against OpenERP version 6.1 and 7.0.

Features

  • Simple way to add new json-rpc entry points
  • Quite easy to get started (see Usage section)
  • Ability to resume an open session (and thus login in openerp) with a saved session_id and HTTP cookie_id (without $login and $password)

Usage

sample PHP code:

<?php

require_once 'openerp.php';

$oe = new PhpOeJson\OpenERP("http://localhost:8069", "test_json");
$oe->login("admin", "xxxxxx");

echo "Logged in (session id: " . $oe->session_id . ")";

$partners = $oe->read(array(
  'model' => 'res.partner',
  'fields' => array('name', 'city'),
));

echo "<ul>";
foreach($partners['records'] as $partner) {
   echo "    <li>" . $partner["name"] . " - " . $partner["city"] . "</li>\n";
}
echo "</ul>";

?>

This actual code (with small modifications) is provided in the example-project directory which is a composer-ready package (more about composer, how to get composer command). This means you can run composer install on the root of the example-project directory to install dependencies, and you'll only have to edit settings.php and set $url, $db and the $login, $password to test it with your installation.

Please note that this is a very thin layer above Tivoka which is a JSON-RPC PHP lib.