diff --git a/rest_api_odoo/README.rst b/rest_api_odoo/README.rst new file mode 100644 index 000000000..e764a1dce --- /dev/null +++ b/rest_api_odoo/README.rst @@ -0,0 +1,54 @@ +.. 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 +============================================== +* Rest Api - Odoo 16 community & Enterprise +* This module allow us to connect to database with REST API requests + +Installation +----------- + * www.odoo.com/documentation/16.0/setup/install.html + * Install our custom addon + +Configuration +----------- +* Set up the config file +* Authentication using POSTman with login credentials +* API key generation +* Communicate with database using API requests + +License +------- +Lesser General Public License v3.0 (LGPL v3) +(https://www.gnu.org/licenses/lgpl-3.0.en.html) + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +Developer : (V16) yadhushankar @ Cybrosys + +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..9693e12fd --- /dev/null +++ b/rest_api_odoo/__init__.py @@ -0,0 +1,24 @@ +# -*- coding:utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# 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..76914b0e7 --- /dev/null +++ b/rest_api_odoo/__manifest__.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# 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", + "description": """The Rest API for Odoo 16""", + "summary": """This app helps to interact with odoo + backend with help of rest api requests""", + "category": "Tools", + "version": "16.0.1.0.0", + '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.png'], + 'license': 'LGPL-3', + 'installable': True, + 'application': True, + 'auto_install': False, +} diff --git a/rest_api_odoo/controllers/__init__.py b/rest_api_odoo/controllers/__init__.py new file mode 100644 index 000000000..0638d3eea --- /dev/null +++ b/rest_api_odoo/controllers/__init__.py @@ -0,0 +1,23 @@ +# -*- coding:utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# 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 main diff --git a/rest_api_odoo/controllers/main.py b/rest_api_odoo/controllers/main.py new file mode 100644 index 000000000..37169cd3b --- /dev/null +++ b/rest_api_odoo/controllers/main.py @@ -0,0 +1,243 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# 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'].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..1dc2f535d --- /dev/null +++ b/rest_api_odoo/doc/RELEASE_NOTES.md @@ -0,0 +1,5 @@ +## Module + +#### 28.12.2023 +#### Version 16.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..e9bf22051 --- /dev/null +++ b/rest_api_odoo/models/__init__.py @@ -0,0 +1,24 @@ +# -*- coding:utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# 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..9e8cf22a0 --- /dev/null +++ b/rest_api_odoo/models/connection_api.py @@ -0,0 +1,47 @@ +# -*- coding:utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# 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..a2d861f36 --- /dev/null +++ b/rest_api_odoo/models/res_users.py @@ -0,0 +1,45 @@ +# -*- coding:utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# 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 UserLogin(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..2c26929a3 --- /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,access.connection.api,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 100644 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 100644 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 100644 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 100644 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 100644 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 100644 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 100644 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 100644 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 100644 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/manufacturing-black.png b/rest_api_odoo/static/description/assets/icons/manufacturing-black.png new file mode 100644 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 100644 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 100644 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 100644 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 100644 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 100644 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 100644 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 100644 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 100644 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 100644 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/categories.png b/rest_api_odoo/static/description/assets/misc/categories.png new file mode 100644 index 000000000..bedf1e0b1 Binary files /dev/null and b/rest_api_odoo/static/description/assets/misc/categories.png differ diff --git a/rest_api_odoo/static/description/assets/misc/check-box.png b/rest_api_odoo/static/description/assets/misc/check-box.png new file mode 100644 index 000000000..42caf24b9 Binary files /dev/null and b/rest_api_odoo/static/description/assets/misc/check-box.png differ diff --git a/rest_api_odoo/static/description/assets/misc/compass.png b/rest_api_odoo/static/description/assets/misc/compass.png new file mode 100644 index 000000000..d5fed8faa Binary files /dev/null and b/rest_api_odoo/static/description/assets/misc/compass.png differ diff --git a/rest_api_odoo/static/description/assets/misc/corporate.png b/rest_api_odoo/static/description/assets/misc/corporate.png new file mode 100644 index 000000000..2eb13edbf Binary files /dev/null and b/rest_api_odoo/static/description/assets/misc/corporate.png differ diff --git a/rest_api_odoo/static/description/assets/misc/customer-support.png b/rest_api_odoo/static/description/assets/misc/customer-support.png new file mode 100644 index 000000000..79efc72ed Binary files /dev/null and b/rest_api_odoo/static/description/assets/misc/customer-support.png differ diff --git a/rest_api_odoo/static/description/assets/misc/cybrosys-logo.png b/rest_api_odoo/static/description/assets/misc/cybrosys-logo.png new file mode 100644 index 000000000..cc3cc0ccf Binary files /dev/null and b/rest_api_odoo/static/description/assets/misc/cybrosys-logo.png differ diff --git a/rest_api_odoo/static/description/assets/misc/features.png b/rest_api_odoo/static/description/assets/misc/features.png new file mode 100644 index 000000000..b41769f77 Binary files /dev/null and b/rest_api_odoo/static/description/assets/misc/features.png differ diff --git a/rest_api_odoo/static/description/assets/misc/logo.png b/rest_api_odoo/static/description/assets/misc/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/rest_api_odoo/static/description/assets/misc/logo.png differ diff --git a/rest_api_odoo/static/description/assets/misc/pictures.png b/rest_api_odoo/static/description/assets/misc/pictures.png new file mode 100644 index 000000000..56d255fe9 Binary files /dev/null and b/rest_api_odoo/static/description/assets/misc/pictures.png differ diff --git a/rest_api_odoo/static/description/assets/misc/pie-chart.png b/rest_api_odoo/static/description/assets/misc/pie-chart.png new file mode 100644 index 000000000..426e05244 Binary files /dev/null and b/rest_api_odoo/static/description/assets/misc/pie-chart.png differ diff --git a/rest_api_odoo/static/description/assets/misc/right-arrow.png b/rest_api_odoo/static/description/assets/misc/right-arrow.png new file mode 100644 index 000000000..730984a06 Binary files /dev/null and b/rest_api_odoo/static/description/assets/misc/right-arrow.png differ diff --git a/rest_api_odoo/static/description/assets/misc/star.png b/rest_api_odoo/static/description/assets/misc/star.png new file mode 100644 index 000000000..2eb9ab29f Binary files /dev/null and b/rest_api_odoo/static/description/assets/misc/star.png differ diff --git a/rest_api_odoo/static/description/assets/misc/support.png b/rest_api_odoo/static/description/assets/misc/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/rest_api_odoo/static/description/assets/misc/support.png differ diff --git a/rest_api_odoo/static/description/assets/misc/whatsapp.png b/rest_api_odoo/static/description/assets/misc/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/rest_api_odoo/static/description/assets/misc/whatsapp.png differ diff --git a/rest_api_odoo/static/description/assets/modules/1.png b/rest_api_odoo/static/description/assets/modules/1.png new file mode 100644 index 000000000..b469963c5 Binary files /dev/null and b/rest_api_odoo/static/description/assets/modules/1.png differ diff --git a/rest_api_odoo/static/description/assets/modules/2.png b/rest_api_odoo/static/description/assets/modules/2.png new file mode 100644 index 000000000..273effef7 Binary files /dev/null and b/rest_api_odoo/static/description/assets/modules/2.png 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..7cc3625c7 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..b51b9c69d 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..2b03b8c31 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.png b/rest_api_odoo/static/description/assets/modules/6.png new file mode 100644 index 000000000..1c98e213f Binary files /dev/null and b/rest_api_odoo/static/description/assets/modules/6.png 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..c00eeb99e 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/screenshot_1.png b/rest_api_odoo/static/description/assets/screenshots/screenshot_1.png new file mode 100644 index 000000000..2bd11417f Binary files /dev/null and b/rest_api_odoo/static/description/assets/screenshots/screenshot_1.png differ diff --git a/rest_api_odoo/static/description/assets/screenshots/screenshot_2.png b/rest_api_odoo/static/description/assets/screenshots/screenshot_2.png new file mode 100644 index 000000000..c892dd068 Binary files /dev/null and b/rest_api_odoo/static/description/assets/screenshots/screenshot_2.png differ diff --git a/rest_api_odoo/static/description/assets/screenshots/screenshot_3.png b/rest_api_odoo/static/description/assets/screenshots/screenshot_3.png new file mode 100644 index 000000000..d12127e35 Binary files /dev/null and b/rest_api_odoo/static/description/assets/screenshots/screenshot_3.png differ diff --git a/rest_api_odoo/static/description/assets/screenshots/screenshot_4.png b/rest_api_odoo/static/description/assets/screenshots/screenshot_4.png new file mode 100644 index 000000000..db9c6608a Binary files /dev/null and b/rest_api_odoo/static/description/assets/screenshots/screenshot_4.png differ diff --git a/rest_api_odoo/static/description/assets/screenshots/screenshot_5.png b/rest_api_odoo/static/description/assets/screenshots/screenshot_5.png new file mode 100644 index 000000000..c06f6e427 Binary files /dev/null and b/rest_api_odoo/static/description/assets/screenshots/screenshot_5.png differ diff --git a/rest_api_odoo/static/description/assets/screenshots/screenshot_6.png b/rest_api_odoo/static/description/assets/screenshots/screenshot_6.png new file mode 100644 index 000000000..3a4fec3cb Binary files /dev/null and b/rest_api_odoo/static/description/assets/screenshots/screenshot_6.png differ diff --git a/rest_api_odoo/static/description/assets/screenshots/screenshot_7.png b/rest_api_odoo/static/description/assets/screenshots/screenshot_7.png new file mode 100644 index 000000000..328235184 Binary files /dev/null and b/rest_api_odoo/static/description/assets/screenshots/screenshot_7.png differ diff --git a/rest_api_odoo/static/description/assets/screenshots/screenshot_8.png b/rest_api_odoo/static/description/assets/screenshots/screenshot_8.png new file mode 100644 index 000000000..dbe866530 Binary files /dev/null and b/rest_api_odoo/static/description/assets/screenshots/screenshot_8.png differ diff --git a/rest_api_odoo/static/description/assets/screenshots/screenshot_9.png b/rest_api_odoo/static/description/assets/screenshots/screenshot_9.png new file mode 100644 index 000000000..635d10ebb Binary files /dev/null and b/rest_api_odoo/static/description/assets/screenshots/screenshot_9.png differ diff --git a/rest_api_odoo/static/description/banner.png b/rest_api_odoo/static/description/banner.png new file mode 100644 index 000000000..63031e083 Binary files /dev/null and b/rest_api_odoo/static/description/banner.png 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..1415589b7 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..bf41854b7 --- /dev/null +++ b/rest_api_odoo/static/description/index.html @@ -0,0 +1,862 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+
+ +
+
+
+ +

+ Odoo rest API

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

+ Explore This + Module

+
+ + + + +
+
+ +
+

+ Overview +

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

+ Features +

+
+
+
+
+ + Api key generation using database authentication. +
+
+
+
+ + Authentication using the generated api key. +
+
+
+ +
+ + Available in Odoo 16.0 Community and Enterprise. +
+
+
+
+ + Can create records for the models we want to access. +
+
+
+ +
+ + Choose specific fields for data fetching. +
+
+
+ +
+ + Choose specific methods like GET, POST etc. +
+
+
+ +
+ + Create and update records from database. +
+
+
+ +
+ + Delete records. +
+
+
+ + + +
+
+ +
+

+ Screenshots +

+
+
+
+ +
+

+ Installing and configuration +

+

+

    +
  • 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. +
  • +
+

+ +
+
+
+
+ +
+

+ Authentication +

+

+

    +
  • Next you have to select the database and login.
  • +
  • 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://cybrosys:8016/odoo_connect + Replace 'cybrosys: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"}.
  • +
+

+ +
+
+

+ Create records in Rest api app +

+

+

    +
  • 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://cybrosys: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://cybrosys: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://cybrosys: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://cybrosys: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"}]}.
  • +
+

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

+ Related + Products +

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

+ Our Services +

+
+ +
+
+
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+ + +
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ 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 86068 + 27707

+
+
+
+
+
+
+
+ +
+
+
+ \ No newline at end of file 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..3e22d7538 --- /dev/null +++ b/rest_api_odoo/views/connection_api_views.xml @@ -0,0 +1,64 @@ + + + + + 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 + + + + + + + + + + +