Availability |
Odoo Online
Odoo.sh
On Premise
|
Odoo Apps Dependencies |
Discuss (mail)
|
Lines of code | 193 |
Technical Name |
fn4media_rest_api |
License | OPL-1 |
Website | http://www.fn4media.in/apps |
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 medetory 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 than 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 medetory 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 medetory 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 medetory 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 medetory 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_button_confirm/ ?token=1ec448c54a004165b4c0da976bmann47
-
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=1ec448c54a004165b4c0da976bmann47&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=1ec448c54a004165b4c0da976bmann47&args={'date_invoice':'2016-09-02'}
-
It will Return :
{"success": "12"}
-
It will Return :
-
Example for calling a method without argument:
-
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module