This question has been flagged
2 Replies
15639 Views

I am aware that I have to structure my xmlrpc query like this:

ids = execute(dbname, uid, pwd, model, 'search', args)
fields = ['field_a', 'field_b', 'field_c']
elements = execute(dbname, uid, pwd, model, 'read', ids, fields)

I need help on structuring the args parameter in order to fetch a list of available elements from these models:

  • res.users as in Settings->Users
  • res.company as in Settings->Companies
  • res.partners as in Sales->Customers and Purchases->Suppliers
  • sale.order as in Sales->Sales Orders
  • account.invoice as in Accounting->Customer Invoices
  • purchase.order as in Purchases->Quotations and Purchases->Purchase Orders

UPDATE 1

Each model fetch request should return all the ids that belong to a given company id.

Avatar
Discard
Best Answer

I see a lot of articles all over the internet talking about how to use xmlrpc on OpenERP 7 and all of them seem to be based on the xmlrpc documentation from the OpenERP 6.

Although not too sure, I think the xmlrpc docs from v6 is mostly outdated for v7.

For starters, there are new methods and endpoints on v7. They are:

  • Method read | /web/dataset/search_read
  • Method authenticate | /web/session/authenticate
  • Method get_session_info | /web/session/get_session_info
  • Method destroy | /web/session/destroy

For those like me interested in implementing a php app, I found this very handy library called php-oe-json hosted at github.

Here are some examples on how to retrieve data from OpenERP 7 using php-oe-json

$oe = new PhpOeJson\OpenERP('http://localhost:8069', 'database_name'); 
$oe->login('admin', 'pwd');

// Get a list of records from a model.
$products = $oe->read(array(
   'model' => 'product.product',
   'fields' => array('name', 'id'),
   'limit' => 20,
   // XXXvlab: bug of openerp 7.0+ which will default domain to "None" if not set, and
   // override of ``_search`` doesn't support ``None`` value.
   'domain' => array(),
));
echo '<pre>';
print_r($products);

// Get a single record from a model.
$so = $oe->read(array(
   'model' => 'sale.order',
   'fields' => array('name', 'id'),
   'limit' => FALSE,
   'domain' => array(array('company_id', '=', 1), array('name', '=', 'SO002')),
));

print_r($so);
Avatar
Discard

So where is the V7 documentation?

There isn't any apparently. My guess is that the php-oe-json author just sniffed into the openerp web module for figuring out how the xmlrpc calls were processed.

Best Answer

I would strongly recommend that you do not try to work with XMLRPC directly.

Have a look at this: Should I use [oerplib] OR [openerp-client-lib] ?

The documentation of oerplib may have an example of what you are trying to do.

Update : When I first started working with XMLRPC APIs, I always found it necessary to start a little library of convenience routines. I'd end up fiddling with it, adding little bits, thinking up cool things to do, etc. etc. Next, thing I knew I'd got yet more code to maintain and all the crap that goes with it. The best way to deal with THAT is to open source it and hope to get collaborators who also need that functionality. It's at the point that I discover a pre-existing library that's much better done than my own and that I should have been using from outset.

Avatar
Discard

Can you post why? Philosophical, Technical, etc?

Author

My hope is to be able to communicate with OpenERP without having to use python. I will take a look at the links you provided. Thank you.

Author

I played with oerplib and apparently it has what I need. Although it would be better if did not have to write my own intermediary python service.

What language are you using then?

Author

PHP.......

Ok. Now it is clear why my answer is less than relevant. Thanks for flagging it as the right answer despite that. If you published a PHP version of oerplib.py on GitHub I expect you'd get some eager collaborators eventually, even if what you put there served exactly your needs and no more..