diff --git a/rest_api_odoo/Postman Collections/Odoo REST Api.postman_collection.zip b/rest_api_odoo/Postman Collections/Odoo REST Api.postman_collection.zip new file mode 100644 index 000000000..d2a8392f5 Binary files /dev/null and b/rest_api_odoo/Postman Collections/Odoo REST Api.postman_collection.zip differ diff --git a/rest_api_odoo/README.rst b/rest_api_odoo/README.rst new file mode 100644 index 000000000..a282c1ddc --- /dev/null +++ b/rest_api_odoo/README.rst @@ -0,0 +1,51 @@ +.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg + :target: https://www.gnu.org/licenses/lgpl-3.0.en.html + :alt: License: LGPL-3 + +Odoo rest API +============= +* This module allow us to connect to database with REST API requests + +Configuration +----------- +* Set up the config file +* Authentication using Postman with login credentials +* API key generation +* Communicate with database using API requests + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +------- +Lesser General Public License v3.0 (LGPL v3) +(https://www.gnu.org/licenses/lgpl-3.0.en.html) + +Credits +------- +Developer : (V16) yadhushankar + (V17) Sruthi pavithran +Contact: odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Maintainer +----------- +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ diff --git a/rest_api_odoo/__init__.py b/rest_api_odoo/__init__.py new file mode 100644 index 000000000..b5d9a8356 --- /dev/null +++ b/rest_api_odoo/__init__.py @@ -0,0 +1,23 @@ +# -*- coding:utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sruthi Pavithran (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import controllers +from . import models diff --git a/rest_api_odoo/__manifest__.py b/rest_api_odoo/__manifest__.py new file mode 100644 index 000000000..af3c23388 --- /dev/null +++ b/rest_api_odoo/__manifest__.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sruthi Pavithran (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +{ + "name": "Odoo rest API", + "version": "17.0.1.0.0", + "category": "Tools", + "summary": """This app helps to interact with odoo, backend with help of + rest api requests""", + "description": """The odoo Rest API module allow us to connect to database + with the help of GET , POST , PUT and DELETE requests""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + "depends": ['base', 'web'], + "data": [ + 'security/ir.model.access.csv', + 'views/res_users_views.xml', + 'views/connection_api_views.xml' + ], + 'images': ['static/description/banner.jpg'], + 'license': 'LGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/rest_api_odoo/controllers/__init__.py b/rest_api_odoo/controllers/__init__.py new file mode 100644 index 000000000..8cb2a4512 --- /dev/null +++ b/rest_api_odoo/controllers/__init__.py @@ -0,0 +1,22 @@ +# -*- coding:utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sruthi Pavithran (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import rest_api_odoo diff --git a/rest_api_odoo/controllers/rest_api_odoo.py b/rest_api_odoo/controllers/rest_api_odoo.py new file mode 100644 index 000000000..53dfbe43e --- /dev/null +++ b/rest_api_odoo/controllers/rest_api_odoo.py @@ -0,0 +1,238 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sruthi Pavithran (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +import json +import logging +from odoo import http +from odoo.http import request + +_logger = logging.getLogger(__name__) + + +class RestApi(http.Controller): + """This is a controller which is used to generate responses based on the + api requests""" + + def auth_api_key(self, api_key): + """This function is used to authenticate the api-key when sending a + request""" + user_id = request.env['res.users'].sudo().search([('api_key', '=', api_key)]) + if api_key is not None and user_id: + response = True + elif not user_id: + response = ('

Invalid API Key ' + '!

') + else: + response = ("

No API Key Provided " + "!

") + return response + + def generate_response(self, method, model, rec_id): + """This function is used to generate the response based on the type + of request and the parameters given""" + option = request.env['connection.api'].search( + [('model_id', '=', model)], limit=1) + model_name = option.model_id.model + if method != 'DELETE': + data = json.loads(request.httprequest.data) + else: + data = {} + fields = [] + if data: + for field in data['fields']: + fields.append(field) + if not fields and method != 'DELETE': + return ("

No fields selected for the model" + "

") + if not option: + return ("

No Record Created for the model" + "

") + try: + if method == 'GET': + fields = [] + for field in data['fields']: + fields.append(field) + if not option.is_get: + return ("

Method Not Allowed" + "

") + else: + datas = [] + if rec_id != 0: + partner_records = request.env[ + str(model_name)].search_read( + domain=[('id', '=', rec_id)], + fields=fields + ) + data = json.dumps({ + 'records': partner_records + }) + datas.append(data) + return request.make_response(data=datas) + else: + partner_records = request.env[ + str(model_name)].search_read( + domain=[], + fields=fields + ) + data = json.dumps({ + 'records': partner_records + }) + datas.append(data) + return request.make_response(data=datas) + except: + return ("

Invalid JSON Data" + "

") + if method == 'POST': + if not option.is_post: + return ("

Method Not Allowed" + "

") + else: + try: + data = json.loads(request.httprequest.data) + datas = [] + new_resource = request.env[str(model_name)].create( + data['values']) + partner_records = request.env[ + str(model_name)].search_read( + domain=[('id', '=', new_resource.id)], + fields=fields + ) + new_data = json.dumps({'New resource': partner_records, }) + datas.append(new_data) + return request.make_response(data=datas) + except: + return ("

Invalid JSON Data" + "

") + if method == 'PUT': + if not option.is_put: + return ("

Method Not Allowed" + "

") + else: + if rec_id == 0: + return ("

No ID Provided" + "

") + else: + resource = request.env[str(model_name)].browse( + int(rec_id)) + if not resource.exists(): + return ("

Resource not found" + "

") + else: + try: + datas = [] + data = json.loads(request.httprequest.data) + resource.write(data['values']) + partner_records = request.env[ + str(model_name)].search_read( + domain=[('id', '=', resource.id)], + fields=fields + ) + new_data = json.dumps( + {'Updated resource': partner_records, + }) + datas.append(new_data) + return request.make_response(data=datas) + + except: + return ("

Invalid JSON Data " + "!

") + if method == 'DELETE': + if not option.is_delete: + return ("

Method Not Allowed" + "

") + else: + if rec_id == 0: + return ("

No ID Provided" + "

") + else: + resource = request.env[str(model_name)].browse( + int(rec_id)) + if not resource.exists(): + return ("

Resource not found" + "

") + else: + + records = request.env[ + str(model_name)].search_read( + domain=[('id', '=', resource.id)], + fields=['id', 'display_name'] + ) + remove = json.dumps( + {"Resource deleted": records, + }) + resource.unlink() + return request.make_response(data=remove) + + @http.route(['/send_request'], type='http', + auth='none', + methods=['GET', 'POST', 'PUT', 'DELETE'], csrf=False) + def fetch_data(self, **kw): + """This controller will be called when sending a request to the + specified url, and it will authenticate the api-key and then will + generate the result""" + http_method = request.httprequest.method + api_key = request.httprequest.headers.get('api-key') + auth_api = self.auth_api_key(api_key) + model = kw.get('model') + username = request.httprequest.headers.get('login') + password = request.httprequest.headers.get('password') + request.session.authenticate(request.session.db, username, + password) + model_id = request.env['ir.model'].search( + [('model', '=', model)]) + if not model_id: + return ("

Invalid model, check spelling or maybe " + "the related " + "module is not installed" + "

") + + if auth_api == True: + if not kw.get('Id'): + rec_id = 0 + else: + rec_id = int(kw.get('Id')) + result = self.generate_response(http_method, model_id.id, rec_id) + return result + else: + return auth_api + + @http.route(['/odoo_connect'], type="http", auth="none", csrf=False, + methods=['GET']) + def odoo_connect(self, **kw): + """This is the controller which initializes the api transaction by + generating the api-key for specific user and database""" + + username = request.httprequest.headers.get('login') + password = request.httprequest.headers.get('password') + db = request.httprequest.headers.get('db') + try: + request.session.update(http.get_default_session(), db=db) + auth = request.session.authenticate(request.session.db, username, + password) + user = request.env['res.users'].browse(auth) + api_key = request.env.user.generate_api(username) + datas = json.dumps({"Status": "auth successful", + "User": user.name, + "api-key": api_key}) + return request.make_response(data=datas) + except: + return ("

wrong login credentials" + "

") diff --git a/rest_api_odoo/doc/RELEASE_NOTES.md b/rest_api_odoo/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..9a7469312 --- /dev/null +++ b/rest_api_odoo/doc/RELEASE_NOTES.md @@ -0,0 +1,5 @@ +## Module + +#### 16.04.2024 +#### Version 17.0.1.0.0 + - Initial Commit for Odoo rest API diff --git a/rest_api_odoo/models/__init__.py b/rest_api_odoo/models/__init__.py new file mode 100644 index 000000000..63f0adaa4 --- /dev/null +++ b/rest_api_odoo/models/__init__.py @@ -0,0 +1,23 @@ +# -*- coding:utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sruthi Pavithran (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import connection_api +from . import res_users diff --git a/rest_api_odoo/models/connection_api.py b/rest_api_odoo/models/connection_api.py new file mode 100644 index 000000000..7c2e55366 --- /dev/null +++ b/rest_api_odoo/models/connection_api.py @@ -0,0 +1,46 @@ +# -*- coding:utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sruthi Pavithran (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import fields, models + + +class ConnectionApi(models.Model): + """This class is used to create an api model in which we can create + records with models and fields, and also we can specify methods.""" + _name = 'connection.api' + _rec_name = 'model_id' + + model_id = fields.Many2one('ir.model', string="Model", + domain="[('transient', '=', False)]", + help="Select model which can be accessed by " + "REST api requests.") + is_get = fields.Boolean(string='GET', + help="Select this to enable GET method " + "while sending requests.") + is_post = fields.Boolean(string='POST', + help="Select this to enable POST method" + "while sending requests.") + is_put = fields.Boolean(string='PUT', + help="Select this to enable PUT method " + "while sending requests.") + is_delete = fields.Boolean(string='DELETE', + help="Select this to enable DELETE method " + "while sending requests.") diff --git a/rest_api_odoo/models/res_users.py b/rest_api_odoo/models/res_users.py new file mode 100644 index 000000000..acfcf0ebc --- /dev/null +++ b/rest_api_odoo/models/res_users.py @@ -0,0 +1,44 @@ +# -*- coding:utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Sruthi Pavithran (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +import uuid +from odoo import fields, models + + +class ResUsers(models.Model): + """This class is used to inherit users and add api key generation""" + _inherit = 'res.users' + + api_key = fields.Char(string="API Key", readonly=True, + help="Api key for connecting with the " + "Database.The key will be " + "generated when authenticating " + "rest api.") + + def generate_api(self, username): + """This function is used to generate api-key for each user""" + users = self.env['res.users'].sudo().search([('login', '=', username)]) + if not users.api_key: + users.api_key = str(uuid.uuid4()) + key = users.api_key + else: + key = users.api_key + return key diff --git a/rest_api_odoo/security/ir.model.access.csv b/rest_api_odoo/security/ir.model.access.csv new file mode 100644 index 000000000..042bd737c --- /dev/null +++ b/rest_api_odoo/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_connection_api_user,access.connection.api.user,model_connection_api,,1,1,1,1 diff --git a/rest_api_odoo/static/description/assets/icons/check.png b/rest_api_odoo/static/description/assets/icons/check.png new file mode 100755 index 000000000..c8e85f51d Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/check.png differ diff --git a/rest_api_odoo/static/description/assets/icons/chevron.png b/rest_api_odoo/static/description/assets/icons/chevron.png new file mode 100755 index 000000000..2089293d6 Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/chevron.png differ diff --git a/rest_api_odoo/static/description/assets/icons/cogs.png b/rest_api_odoo/static/description/assets/icons/cogs.png new file mode 100755 index 000000000..95d0bad62 Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/cogs.png differ diff --git a/rest_api_odoo/static/description/assets/icons/consultation.png b/rest_api_odoo/static/description/assets/icons/consultation.png new file mode 100755 index 000000000..8319d4baa Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/consultation.png differ diff --git a/rest_api_odoo/static/description/assets/icons/ecom-black.png b/rest_api_odoo/static/description/assets/icons/ecom-black.png new file mode 100755 index 000000000..a9385ff13 Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/ecom-black.png differ diff --git a/rest_api_odoo/static/description/assets/icons/education-black.png b/rest_api_odoo/static/description/assets/icons/education-black.png new file mode 100755 index 000000000..3eb09b27b Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/education-black.png differ diff --git a/rest_api_odoo/static/description/assets/icons/hotel-black.png b/rest_api_odoo/static/description/assets/icons/hotel-black.png new file mode 100755 index 000000000..130f613be Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/hotel-black.png differ diff --git a/rest_api_odoo/static/description/assets/icons/license.png b/rest_api_odoo/static/description/assets/icons/license.png new file mode 100755 index 000000000..a5869797e Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/license.png differ diff --git a/rest_api_odoo/static/description/assets/icons/lifebuoy.png b/rest_api_odoo/static/description/assets/icons/lifebuoy.png new file mode 100755 index 000000000..658d56ccc Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/lifebuoy.png differ diff --git a/rest_api_odoo/static/description/assets/icons/logo.png b/rest_api_odoo/static/description/assets/icons/logo.png new file mode 100755 index 000000000..478462d3e Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/logo.png differ diff --git a/rest_api_odoo/static/description/assets/icons/manufacturing-black.png b/rest_api_odoo/static/description/assets/icons/manufacturing-black.png new file mode 100755 index 000000000..697eb0e9f Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/manufacturing-black.png differ diff --git a/rest_api_odoo/static/description/assets/icons/pos-black.png b/rest_api_odoo/static/description/assets/icons/pos-black.png new file mode 100755 index 000000000..97c0f90c1 Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/pos-black.png differ diff --git a/rest_api_odoo/static/description/assets/icons/puzzle.png b/rest_api_odoo/static/description/assets/icons/puzzle.png new file mode 100755 index 000000000..65cf854e7 Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/puzzle.png differ diff --git a/rest_api_odoo/static/description/assets/icons/restaurant-black.png b/rest_api_odoo/static/description/assets/icons/restaurant-black.png new file mode 100755 index 000000000..4a35eb939 Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/restaurant-black.png differ diff --git a/rest_api_odoo/static/description/assets/icons/service-black.png b/rest_api_odoo/static/description/assets/icons/service-black.png new file mode 100755 index 000000000..301ab51cb Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/service-black.png differ diff --git a/rest_api_odoo/static/description/assets/icons/trading-black.png b/rest_api_odoo/static/description/assets/icons/trading-black.png new file mode 100755 index 000000000..9398ba2f1 Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/trading-black.png differ diff --git a/rest_api_odoo/static/description/assets/icons/training.png b/rest_api_odoo/static/description/assets/icons/training.png new file mode 100755 index 000000000..884ca024d Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/training.png differ diff --git a/rest_api_odoo/static/description/assets/icons/update.png b/rest_api_odoo/static/description/assets/icons/update.png new file mode 100755 index 000000000..ecbc5a01a Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/update.png differ diff --git a/rest_api_odoo/static/description/assets/icons/user.png b/rest_api_odoo/static/description/assets/icons/user.png new file mode 100755 index 000000000..6ffb23d9f Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/user.png differ diff --git a/rest_api_odoo/static/description/assets/icons/wrench.png b/rest_api_odoo/static/description/assets/icons/wrench.png new file mode 100755 index 000000000..6c04dea0f Binary files /dev/null and b/rest_api_odoo/static/description/assets/icons/wrench.png differ diff --git a/rest_api_odoo/static/description/assets/misc/Cybrosys R.png b/rest_api_odoo/static/description/assets/misc/Cybrosys R.png new file mode 100755 index 000000000..da4058087 Binary files /dev/null and b/rest_api_odoo/static/description/assets/misc/Cybrosys R.png differ diff --git a/rest_api_odoo/static/description/assets/misc/email.svg b/rest_api_odoo/static/description/assets/misc/email.svg new file mode 100755 index 000000000..15291cdc3 --- /dev/null +++ b/rest_api_odoo/static/description/assets/misc/email.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rest_api_odoo/static/description/assets/misc/phone.svg b/rest_api_odoo/static/description/assets/misc/phone.svg new file mode 100755 index 000000000..b7bd7f251 --- /dev/null +++ b/rest_api_odoo/static/description/assets/misc/phone.svg @@ -0,0 +1,3 @@ + + + diff --git a/rest_api_odoo/static/description/assets/misc/star (1) 2.svg b/rest_api_odoo/static/description/assets/misc/star (1) 2.svg new file mode 100755 index 000000000..5ae9f507a --- /dev/null +++ b/rest_api_odoo/static/description/assets/misc/star (1) 2.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/rest_api_odoo/static/description/assets/misc/support (1) 1.svg b/rest_api_odoo/static/description/assets/misc/support (1) 1.svg new file mode 100755 index 000000000..7d37a8f30 --- /dev/null +++ b/rest_api_odoo/static/description/assets/misc/support (1) 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/rest_api_odoo/static/description/assets/misc/support-email.svg b/rest_api_odoo/static/description/assets/misc/support-email.svg new file mode 100755 index 000000000..eb70370d6 --- /dev/null +++ b/rest_api_odoo/static/description/assets/misc/support-email.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/rest_api_odoo/static/description/assets/misc/tick-mark.svg b/rest_api_odoo/static/description/assets/misc/tick-mark.svg new file mode 100755 index 000000000..2dbb40187 --- /dev/null +++ b/rest_api_odoo/static/description/assets/misc/tick-mark.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/rest_api_odoo/static/description/assets/misc/whatsapp 1.svg b/rest_api_odoo/static/description/assets/misc/whatsapp 1.svg new file mode 100755 index 000000000..0bfaf8fc6 --- /dev/null +++ b/rest_api_odoo/static/description/assets/misc/whatsapp 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/rest_api_odoo/static/description/assets/misc/whatsapp.svg b/rest_api_odoo/static/description/assets/misc/whatsapp.svg new file mode 100755 index 000000000..b618aea1d --- /dev/null +++ b/rest_api_odoo/static/description/assets/misc/whatsapp.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rest_api_odoo/static/description/assets/modules/1.gif b/rest_api_odoo/static/description/assets/modules/1.gif new file mode 100644 index 000000000..8ac32db03 Binary files /dev/null and b/rest_api_odoo/static/description/assets/modules/1.gif differ diff --git a/rest_api_odoo/static/description/assets/modules/2.jpg b/rest_api_odoo/static/description/assets/modules/2.jpg new file mode 100644 index 000000000..d05b1744e Binary files /dev/null and b/rest_api_odoo/static/description/assets/modules/2.jpg differ diff --git a/rest_api_odoo/static/description/assets/modules/3.png b/rest_api_odoo/static/description/assets/modules/3.png new file mode 100644 index 000000000..10c9f3807 Binary files /dev/null and b/rest_api_odoo/static/description/assets/modules/3.png differ diff --git a/rest_api_odoo/static/description/assets/modules/4.png b/rest_api_odoo/static/description/assets/modules/4.png new file mode 100644 index 000000000..d7ef56df4 Binary files /dev/null and b/rest_api_odoo/static/description/assets/modules/4.png differ diff --git a/rest_api_odoo/static/description/assets/modules/5.png b/rest_api_odoo/static/description/assets/modules/5.png new file mode 100644 index 000000000..3bedf7981 Binary files /dev/null and b/rest_api_odoo/static/description/assets/modules/5.png differ diff --git a/rest_api_odoo/static/description/assets/modules/6.jpg b/rest_api_odoo/static/description/assets/modules/6.jpg new file mode 100644 index 000000000..67c7f7062 Binary files /dev/null and b/rest_api_odoo/static/description/assets/modules/6.jpg differ diff --git a/rest_api_odoo/static/description/assets/screenshots/hero.gif b/rest_api_odoo/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..29e47473a Binary files /dev/null and b/rest_api_odoo/static/description/assets/screenshots/hero.gif differ diff --git a/rest_api_odoo/static/description/assets/screenshots/rest_api.png b/rest_api_odoo/static/description/assets/screenshots/rest_api.png new file mode 100644 index 000000000..daaebe23b Binary files /dev/null and b/rest_api_odoo/static/description/assets/screenshots/rest_api.png differ diff --git a/rest_api_odoo/static/description/assets/screenshots/rest_api_1.png b/rest_api_odoo/static/description/assets/screenshots/rest_api_1.png new file mode 100644 index 000000000..62c63630a Binary files /dev/null and b/rest_api_odoo/static/description/assets/screenshots/rest_api_1.png differ diff --git a/rest_api_odoo/static/description/assets/screenshots/rest_api_2.png b/rest_api_odoo/static/description/assets/screenshots/rest_api_2.png new file mode 100644 index 000000000..45063358e Binary files /dev/null and b/rest_api_odoo/static/description/assets/screenshots/rest_api_2.png differ diff --git a/rest_api_odoo/static/description/assets/screenshots/rest_api_3.png b/rest_api_odoo/static/description/assets/screenshots/rest_api_3.png new file mode 100644 index 000000000..3d5367f65 Binary files /dev/null and b/rest_api_odoo/static/description/assets/screenshots/rest_api_3.png differ diff --git a/rest_api_odoo/static/description/assets/screenshots/rest_api_4.png b/rest_api_odoo/static/description/assets/screenshots/rest_api_4.png new file mode 100644 index 000000000..55b5f42e6 Binary files /dev/null and b/rest_api_odoo/static/description/assets/screenshots/rest_api_4.png differ diff --git a/rest_api_odoo/static/description/assets/screenshots/rest_api_5.png b/rest_api_odoo/static/description/assets/screenshots/rest_api_5.png new file mode 100644 index 000000000..2bfe803c0 Binary files /dev/null and b/rest_api_odoo/static/description/assets/screenshots/rest_api_5.png differ diff --git a/rest_api_odoo/static/description/banner.jpg b/rest_api_odoo/static/description/banner.jpg new file mode 100644 index 000000000..8c4479884 Binary files /dev/null and b/rest_api_odoo/static/description/banner.jpg differ diff --git a/rest_api_odoo/static/description/icon.png b/rest_api_odoo/static/description/icon.png new file mode 100644 index 000000000..cad97cbb3 Binary files /dev/null and b/rest_api_odoo/static/description/icon.png differ diff --git a/rest_api_odoo/static/description/index.html b/rest_api_odoo/static/description/index.html new file mode 100644 index 000000000..9f8a37823 --- /dev/null +++ b/rest_api_odoo/static/description/index.html @@ -0,0 +1,1087 @@ + + + + + + Odoo App 3 Index + + + + + + + + +
+
+
+
+
+ +
+
+
+ Community +
+
+ Enterprise +
+
+
+
+
+
+

+ Odoo rest API

+

+ The odoo Rest API module allow us to connect to database + with the help of GET , POST , PUT and DELETE request. +

+
+ +
+
+
+
+
+

+ Key Highlights +

+
+
+
+
+
+ +
+
+

+ Api Key Generation

+

This module + Api key generation using database + authentication. +

+
+
+
+
+
+
+ +
+
+

+ Create Records

+

Can create + records for the models we want to access. +

+
+
+
+
+
+
+ +
+
+

+ Methods

+

This module + Choose specific methods like GET, POST etc. +

+
+
+
+
+
+
+ +
+
+

+ Create & Updates

+

Create and + update records from database. +

+
+
+
+
+
+
+ +
+
+

+ Delete

+

This module + Choose DELETE method to delete records. +

+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+ +
+
+

+
    +
  • First of all, we have to add a new + parameter in odoo conf. + file. +
  • +
  • server_wide_modules = web, base, + rest_api_odoo
    + - This will allow us to send request + to + server without + selecting database first.
    - + Incase + if you have to + uninstall the module , you have to + remove this parameter. +
    - Next we can install the + module. +
  • +
  • After installing the Rest api app we + can + see a new api key + field in users. +
  • + - Next we have to generate the api-key + for + the current + user.
    +
  • You can import the postman + collections + provided in the app + folder for authentication and + interacting with database in + various methods. +
  • +
+

+
+
+
+
+
+
+ +
+
+

+
    +
  • We have attached Postman + collections through which + you can + authenticate rest api. +
  • +
  • First, extract the zip file. + Then, you will obtain the + JSON-format + file, which you can directly import + into + POSTMAN.
  • +
  • The url format will be like this - + http://localhost:8017/odoo_connect + Replace 'localhost:8016' with your + localhost port number. +
  • +
  • You have to provide database name, + username and password + through the headers while sending + request. +
  • +
  • If the authentication is successful + , an + api key will be + generated for the current user. +
  • +
  • This key will be used when sending + api + requests to + database. +
  • +
  • The response will be like this - + {"Status": "auth + successful", "User": "Mitchell + Admin", + "api-key": + "66c2ebab-d4dc-42f0-87d0-d1646e887569"}. +
  • +
+

+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+

+
    +
  • After rest api authentication, we + can + create records in the + rest api app. +
  • +
  • Here we can choose the model, and + also + we can + choose the http methods. +
  • +
  • The api response will be based on + these + records. +
  • +
+

+
+
+
+
+
+
+

+ Get Records

+
+
+
+
+
+
+
    +
  • You can send GET request to retrieve + data from the + database. +
  • +
  • The postman collection has been provided + with--> + app files for + sending request from postman. +
  • +
  • You have to provide username, password + and api + key through + the header. +
  • +
  • Model can be passed as argument as the + technical + name , and + also if you want + specific record you can provide the id + as well, +
  • +
  • The format for GET method will be like + this + http://localhost:8016/send_request?model=res.partner&Id=10. +
  • +
  • We can specify the fields inside the + JSON data, + and it will + be like this - {"fields": ["name", + "email"]}.
  • +
  • This is the format of api response - {"records": + [{"id": + 10, "email": + "deco.addict82@example.com", + "name": "Deco + Addict"}]}. +
  • + +
+
+
+
+
+
+
+

+ Create Records

+
+
+
+
+
+
+

+
    +
  • Using POST method , you can create + new records + in the + database. +
  • +
  • Just make sure you enabled POST + method for the + model record + in rest api app , otherwise you will + get 'method + not + allowed' message. +
  • +
  • For creating record you have to + provide the JSON + data along + with the model. +
  • +
  • You can make use of the postman + collection that + we have + added with app files. +
  • +
  • The format for sending POST request + will be like + this - http://localhost:8016/send_request?model=res.partner. +
  • +
  • This is the format for JSON data - + { + "fields" :["name", "phone"] , + "values": {"name": "abc", + "phone":"55962441552" + } }. +
  • +
  • Make sure the data entered in + correct format + otherwise you + will get 'Invalid JSON data' + message. +
  • +
  • Response will be in this format - + {"New + resource": + [{"id": 51, "name": "abc", + "phone": + "55962441552"}]}. +
  • +
+

+
+
+
+
+
+
+

+ Update Records

+
+
+
+
+
+
+

+
    +
  • Updation of records in the database + can be done + with PUT + method. +
  • +
  • You have to provide the model and + also the id or + the record + that you want to update. +
  • +
  • You can use the Postman collection + that we have + provided and , you + will be always have to send request + with your + login + credentials. Otherwise, it will be + showing + access denied. +
  • +
  • The format for sending PUT request + will be like + this - http://localhost:8016/send_request?model=res.partner&Id=46. +
  • +
  • Here too you have to provide the + JSON data + through which the + updates will be done. +
  • +
  • The response format will be like + this - {"Updated + resource": [{"id": 46, "email": + "abc@example.com", "name": + "Toni"}]}.
  • +
+

+
+
+
+
+
+
+

+ Delete Records

+
+
+
+
+
+
+

+
    +
  • Database records can be deleted by + sending + DELETE method + request. +
  • +
  • For the deletion we have to provide + the Model + and the record + id that we want to delete. +
  • +
  • Make sure you have permission to + delete files + for the + selected model in the rest api + record. +
  • +
  • The delete request format will be + like this - + http://localhost:8016/send_request?model=res.partner&Id=46. +
  • +
  • The response after successful + deletion will be + - + {"Resource deleted": [{"id": 46, + "email": + "abc@example.com", + "name": "Toni"}]}.
  • +
+

+
+
+
+
+
+
+
    +
  • + We can create + records in the rest api app. +
  • +
  • + We can send GET + request to retrieve data from the database. +
  • +
  • + Update of + records in the database can be done with PUT + method. +
  • +
  • + Database records + can be deleted by sending DELETE method request. +
  • +
+
+
+
+
+
+
Version + 17.0.1.0.0|Released on:29th Mar 2024 +
+

+ Initial Commit for Odoo rest API.

+
+
+
+
+
+
+
+

+ Related Products

+
+
+ +
+
+

+ Our Services

+ +
+
+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Customization

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Implementation

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Support

+
+
+
+
+
+
+ service-icon +
+
+

Hire + Odoo Developer

+
+
+
+
+ +
+
+ service-icon +
+
+

Odoo + Integration

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Migration

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Consultancy

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Implementation

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Licensing Consultancy

+
+
+
+
+
+
+

+ Our Industries

+ +
+
+
+
+
+
+ +

Trading

+

Easily procure and sell your products

+
+
+
+
+ +

POS

+

Easy configuration and convivial experience

+
+
+
+
+ +

+ Education

+

A platform for educational management

+
+
+
+
+ +

+ Manufacturing

+

Plan, track and schedule your operations

+
+
+
+
+ +

E-commerce + & Website

+

Mobile friendly, awe-inspiring product pages

+
+
+
+
+ +

Service + Management

+

Keep track of services and invoice

+
+
+
+
+ +

+ Restaurant

+

Run your bar or restaurant methodically

+
+
+
+
+ +

Hotel + Management

+

An all-inclusive hotel management application

+
+
+
+
+
+
+

+ Support

+
+
+
+
+
+
+
+ +
+ Need + Help? +

Got + questions or need help? Get in touch.

+
odoo@cybrosys.com +
+
+
+
+
+
+
+
+ +
+ WhatsApp +

Say hi to + us on WhatsApp!

+
+91 + 99456767686 +
+
+
+
+
+
+
+
+
+ + + + + + diff --git a/rest_api_odoo/views/connection_api_views.xml b/rest_api_odoo/views/connection_api_views.xml new file mode 100644 index 000000000..747162c73 --- /dev/null +++ b/rest_api_odoo/views/connection_api_views.xml @@ -0,0 +1,61 @@ + + + + + connection.api.view.form + connection.api + +
+ + + + + + + + + + + + + +
+
+
+ + + connection.api.view.tree + connection.api + + + + + + + + + + + + + Rest API Records + ir.actions.act_window + connection.api + tree,form + +

+ Create! +

+
+
+ + + +
diff --git a/rest_api_odoo/views/res_users_views.xml b/rest_api_odoo/views/res_users_views.xml new file mode 100644 index 000000000..c6a59b1ef --- /dev/null +++ b/rest_api_odoo/views/res_users_views.xml @@ -0,0 +1,18 @@ + + + + + view.users.form.inherit.rest.api.odoo + + res.users + + + + + + + + + + +