0k/php-oe-json

OpenERP Json query

0.0.2 2014-01-28 08:44 UTC

This package is not auto-updated.

Last update: 2024-12-21 15:44:40 UTC


README

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.