Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
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
- res.company as in
- res.partners as in
- sale.order as in
- account.invoice as in
- purchase.order as in
Each model fetch request should return all the ids that belong to a given company id.
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:
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);
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.
About This Community
This platform 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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 4/15/14, 4:43 AM|
|Seen: 4134 times|
|Last updated: 3/16/15, 8:10 AM|