From 80934c89831803ff03b559284f5d70e1c1a338fb Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Thu, 10 Feb 2022 01:34:08 -0500 Subject: [PATCH 1/2] [ADD] manifest new repo: ajepe odoo-addons to get module restful --- manifest/default.dev.xml | 2 ++ script/generate_config.sh | 1 + source_repo_addons.csv | 1 + 3 files changed, 4 insertions(+) diff --git a/manifest/default.dev.xml b/manifest/default.dev.xml index 4f8d1b1..5a1d7c0 100644 --- a/manifest/default.dev.xml +++ b/manifest/default.dev.xml @@ -7,6 +7,7 @@ + @@ -92,6 +93,7 @@ + diff --git a/script/generate_config.sh b/script/generate_config.sh index 3c0fc2d..2593caf 100755 --- a/script/generate_config.sh +++ b/script/generate_config.sh @@ -128,6 +128,7 @@ if [[ ${EL_MINIMAL_ADDONS} = "False" ]]; then printf "${EL_HOME}/addons/Smile-SA_odoo_addons," >> ${EL_CONFIG_FILE} printf "${EL_HOME}/addons/TechnoLibre_odoo-code-generator," >> ${EL_CONFIG_FILE} printf "${EL_HOME}/addons/TechnoLibre_odoo-code-generator-template," >> ${EL_CONFIG_FILE} + printf "${EL_HOME}/addons/ajepe_odoo-addons," >> ${EL_CONFIG_FILE} printf "${EL_HOME}/addons/camptocamp_odoo-cloud-platform," >> ${EL_CONFIG_FILE} printf "${EL_HOME}/addons/dhongu_deltatech," >> ${EL_CONFIG_FILE} printf "${EL_HOME}/addons/it-projects-llc_saas-addons," >> ${EL_CONFIG_FILE} diff --git a/source_repo_addons.csv b/source_repo_addons.csv index 4f3ec07..5f7bef2 100644 --- a/source_repo_addons.csv +++ b/source_repo_addons.csv @@ -131,3 +131,4 @@ https://github.com/TechnoLibre/odoo-code-generator-template.git,addons,, https://github.com/ERPLibre/ERPLibre_image_db.git,,, https://github.com/odoo/design-themes.git,addons,, https://github.com/novacode-nl/odoo-formio.git,addons,, +https://github.com/ajepe/odoo-addons.git,addons,, From 0a800a05066165c8e260e90c04ef780209225d50 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Thu, 10 Feb 2022 02:03:38 -0500 Subject: [PATCH 2/2] [ADD] script restful: documentation and example --- script/restful/README.md | 25 ++++++++++++++++++ script/restful/restful_example.py | 44 +++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 script/restful/README.md create mode 100755 script/restful/restful_example.py diff --git a/script/restful/README.md b/script/restful/README.md new file mode 100644 index 0000000..ce073fc --- /dev/null +++ b/script/restful/README.md @@ -0,0 +1,25 @@ +# Restful + +REST (representational state transfer) service in ERPLibre, create a token and get data. + +## Installation + +In your instance, install module `restful`. + +## Example + +The example works with application Helpdesk, install module `helpdesk_mgmt`. + +You need to run with specified database, and you can run the example script. + +```bash +./script/db_restore.py --database test +./script/addons/install_addons.sh test restful,helpdesk_mgmt +./run.sh -d test +``` + +Test with the example while the server is running. You can add data manually. + +```bash +./script/restful/restful_example.py +``` diff --git a/script/restful/restful_example.py b/script/restful/restful_example.py new file mode 100755 index 0000000..bdf0e10 --- /dev/null +++ b/script/restful/restful_example.py @@ -0,0 +1,44 @@ +#!./.venv/bin/python +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import json + +import requests + +headers = { + "content-type": "application/x-www-form-urlencoded", + "charset": "utf-8", +} + +data = {"login": "admin", "password": "admin", "db": "test"} + +base_url = "http://127.0.0.1:8069" + +req = requests.get(f"{base_url}/api/auth/token", data=data, headers=headers) + +response = req.content.decode("utf-8") + +print(response) + +content = json.loads(response) + +headers["access-token"] = content.get("access_token") +# add the access token to the header + +print(headers) + +model_name = "helpdesk.ticket" +req = requests.get( + f"{base_url}/api/{model_name}/", + headers=headers, + data={"limit": 10, "domain": []}, +) + +# ***Pass optional parameter like this, with data = *** +# { +# "limit": 10, +# "domain": "[('supplier','=',True),('parent_id','=', False)]", +# "order": "name asc", +# "offset": 10, +# } + +print(req.content)