Availability |
Odoo Online
Odoo.sh
On Premise
|
Odoo Apps Dependencies |
Discuss (mail)
|
Lines of code | 193 |
Technical Name |
rest_api_drc |
Website | http://www.drcsystems.com |
Versions | 8.0 9.0 10.0 11.0 12.0 |
Features
-
Available Operations
-
Get Token :
Odoo requires users of the API to be authenticated before they can use any other API. Authentication itself is done through the authenticate function and returns Token. On Every API call user must send a token to Access any API.
-
Example:
localhost:8069/api/user/get_token?login=admin&password=admin
It will Return:{"token": "24e635ff9cc74429bed3d420243f5aa6"} # If authentication done.
-
Example:
-
Delete Token :
User can delete token so, API call is not allow to access by that token On Detele token API call user must send a token.
-
Example:
localhost:8069/api/user/delete_token?token=24e635ff9cc74429bed3d420243f5aa6
Return:
{"success": "Token '24e635ff9cc74429bed3d420243f5aa6' Deleted Successfully"}
-
Example:
-
Refresh Token :
User can Refresh token so, token will be updated and return new token. On Refresh token API call user must send a token.
-
Example:
localhost:8069/api/user/refresh_token?token=24e635ff9cc74429bed3d420243f5aa6
Return:
{"token": "cd7bdf0dfb7d4d74b08d3eae84af934c"}
-
Example:
-
Search Record:
list records , it is mandatory to pass model name if id is pass with url then return a single record of a specific id Found else check domain in post data , if domain is found then return matched records else return all the data with id and name field.
By default a search will return the ids and name of all records matching the condition, which may be a huge number.if offset and limit parameters are available to only retrieve a subset of all matched records.
By default a search will return the ids and name of all records matching the condition, it may possible that also you want to read other fields name with that name and ids. Note: it will always returns id as default field name if field name is not given it will return (id and name) otherwise it will return (id and all given fields name).
-
Example for single record :
localhost:8069/api/res.partner/search/1?token=24e635ff9cc74429bed3d420243f5aa6
-
Example for search using domain, offset and limit
localhost:8069/api/res.partner/search?token=cd7bdf0dfb7d4d74b08d3eae84af934c& &domain=[('customer','=', True)]&offset=10&limit=2&fields=['name','phone']
-
It will Return :
[ { "phone": "+44 121 690 4596", "id": 25, "name": "David Simpson" }, { "phone": false, "id": 35, "name": "Jacob Taylor" }, ]
-
It will Return :
-
Example for single record :
-
Create Record:
create record , it is mandatory to pass model name and values for record creation pass as create_vals of JOSN/Dictionary format. .
-
Example:
localhost:8069/api/product.product/create?token=24e635ff9cc74429bed3d420243f5aa6& create_vals={'name':'Apple'}
-
It will Return :
{'id':101}
-
It will Return :
-
Example:
-
Update Record:
update record , it is mandatory to pass model name and record id and values for record update pass as update_vals in JOSN/Dictionary format.
-
Example:
localhost:8069/api/product.product/update/101?token=24e635ff9cc74429bed3d420243f5aa6& update_vals={'name':'Mango'}
-
It will Return :
{'success':'Record Updated Successfully'}
-
It will Return :
-
Example:
-
Delete Record:
Delete record , it is mandatory to pass model name and record id For Delete multiple records pass record ids in url parameter as 'unlink_ids' as in list format.
-
Example for single record:
localhost:8069/api/product.product/unlink/59?token=24e635ff9cc74429bed3d420243f5aa6
-
It will Return :
{'success':'Records Successfully Deleted 59'}
-
It will Return :
-
Example for multi record:
localhost:8069/api/product.product/unlink/?token=24e635ff9cc74429bed3d420243f5aa6& unlink_ids=[60,61]
-
It will Return :
{'success':'Records Successfully Deleted [60,61]'}
-
It will Return :
-
Example for single record:
-
Calling method of any model :
For calling a method of any model , it is mandatory to pass model name, record id and method name method call based on new api standards. so no need to pass cr,uid,ids,context as method argument. Other then this argument pass as 'args'=[arg1,arg2] in query string
-
Example for calling a method without argument:
localhost:8069/api/sale.order/26/method/action_confirm/ ?token=1ec448c54a004165b4c0da976b227260
-
It will Return :
{"success": "True"}
It will return dictionary its key 'success' and and its value is as per return value of calling method
-
It will Return :
-
Example for calling method with arguments:
def get_salenote(self, partner_id)' this method is of sale.order model. For calling this method we need to pass partner_id as argument
localhost:8069/api/sale.order/35/method/get_salenote/ ?token=1ec448c54a004165b4c0da976b227260&args=[3]
-
It will Return :
{"success": "sale note"}
-
It will Return :
-
Example for calling method with keyword arguments:
localhost:8069/api/sale.order/33/method/action_invoice_create/? token=1ec448c54a004165b4c0da976b227260&args={'date_invoice':'2016-09-02'}
-
It will Return :
{"success": "12"}
-
It will Return :
-
Example for calling a method without argument:
-
Please log in to comment on this module
Report comment
Any abuse of this reporting system will be penalizedThere are no ratings yet!
hi,
can we create the wizard-like records
like payment for a particular invoice?
Question before purchase?
Does this work on an odoo server with multiple databases?
How do I select the database in the end point url?
User management
Hi, I'm wondering if when creating, reading and updating records, and also calling methods, the API is impersonating the user with which the token was generated, meaning that if this is returning the records the user has grants to, and also for logging matters if odoo is saving using that very same user for tracking record updating and creation matters