Question

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.

Was it helpful?

Solution 2

My answer at OpenERP Q & A, and by Martin H. Bramwell. Mine follows:

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);

OTHER TIPS

The args parameter may be used to pass conditions for matching records (sql where clause):

args = [('name', '=', 'admin')]
ids = sock.execute(dbname, uid, pwd, 'res.users', 'search', args)

will retrieve the id for the admin user record (if any).

args is an array of 3-tuples.

Docs here: https://doc.openerp.com/6.0/developer/6_22_XML-RPC_web_services/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top