Odoo Rest API
This module adds full support for Rest API in Odoo
FEATURES:
POSSIBLE REQUESTS:
EXAMPLES:
[Example 1] - Get all users data - selected fields
Request:curl -X GET -u admin:admin -H "Content-Type: text/html" http://localhost:8069/rest/res.users -d "{'fields': ['name', 'login']}"Response
[ { "id": 1, "login": "admin", "name": "Administrator" }, { "id": 6, "login": "portal", "name": "Demo Portal User" }, { "id": 5, "login": "demo", "name": "Demo User" }, { "id": 7, "login": "support@gksoftware.pl", "name": "Grzegorz" } ]
[Example 2] - Search users: name contains 'demo'
Request:curl -X GET -u admin:admin -H "Content-Type: text/html" http://localhost:8069/rest/res.users -d "{'domain': [['name', 'ilike', 'demo']], 'fields': ['name']}"Response
[ { "id": 6, "name": "Demo Portal User" }, { "id": 5, "name": "Demo User" } ]
[Example 3] - Get partners - selected ids
Request:curl -X GET -u admin:admin -H "Content-Type: text/html" http://localhost:8069/rest/res.partner/25,26 -d "{'fields': ['name']}"Response
[ { "id": 25, "name": "Chao Wang" }, { "id": 26, "name": "David Simpson" } ]
[Example 4] - Create record
Request:curl -X POST -u admin:admin -H "Content-Type: text/html" http://localhost:8069/rest/res.partner -d "{'name': 'Created Partner'}"Response
46
[Example 5] - Update 3 records with one request
Request:curl -X PUT -u admin:admin -H "Content-Type: text/html" http://localhost:8069/rest/res.partner/25,26,46 -d "{'name': 'New name'}"Response
true
[Example 6] - Delete selected records
Request:curl -X DELETE -u admin:admin -H "Content-Type: text/html" http://localhost:8069/rest/res.partner/26,46Response
true
[Example 7] - Execute model method - confirm sale order
Request:curl -X POST -u admin:admin -H "Content-Type: text/html" http://localhost:8069/rest/sale.order/action_confirm/3Response
trueAny questions?
Want to test this module?
Email me: support@gksoftware.pl
Please log in to comment on this module
Report comment
Any abuse of this reporting system will be penalizedThere are no ratings yet!
More info
Just noticed my post yesterday was under the v9 release, but, I'm running v11, using the v11 Rest code.
Request on post scrambled
Here's the POST without html in the body field, which was scrambled when in previous: {'body':'Here’s my picture', 'model':'mail.channel', 'res_id':22, 'message_type':'comment', 'subtype_id':1, 'attachment_ids':[4503]}
Update does not work on many2many field
I have a very basic update on mail.message using: curl -X POST -u admin:*** -H "Content-Type: text/html" http://dev.myserver.com:8010/rest/mail.message -d "{'body':'
Here’s my picture
','model':'mail.channel','res_id':22,'message_type':'comment','subtype_id':1,'attachment_ids':[4503]}" and all fields update, except attachment_ids value, which is a many2many field. The value of 4503 is valid on the ir_attachment and has values of res_model="mail.channel" and res_id=22, matching the keys in the above. I have tried many formats for the attachment_ids field value, but, nothing works. How do I update this field using your api? Thanks!