Merge pull request #46 from ERPLibre/ajepe_odoo-addons

Ajepe odoo addons - module restful
This commit is contained in:
Mathieu Benoit 2022-02-10 20:45:12 -05:00 committed by GitHub
commit 6af622e51d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 73 additions and 0 deletions

View file

@ -7,6 +7,7 @@
<remote name="OCA" fetch="https://github.com/ERPLibre/"/>
<remote name="Smile-SA" fetch="https://github.com/ERPLibre/"/>
<remote name="TechnoLibre" fetch="https://github.com/ERPLibre/"/>
<remote name="ajepe" fetch="https://github.com/ERPLibre/"/>
<remote name="camptocamp" fetch="https://github.com/ERPLibre/"/>
<remote name="dhongu" fetch="https://github.com/ERPLibre/"/>
<remote name="it-projects-llc" fetch="https://github.com/ERPLibre/"/>
@ -92,6 +93,7 @@
<project name="muk_web.git" path="addons/muk-it_muk_web" remote="muk-it" revision="12.0_dev" groups="addons,base"/>
<project name="muk_website.git" path="addons/muk-it_muk_website" remote="muk-it" revision="12.0_remove_autoinstall" groups="addons,base"/>
<project name="multi-company.git" path="addons/OCA_multi-company" remote="OCA" groups="addons"/>
<project name="odoo-addons.git" path="addons/ajepe_odoo-addons" remote="ajepe" groups="addons"/>
<project name="odoo-base-addons.git" path="addons/Numigi_odoo-base-addons" remote="Numigi" revision="12.0_dev" groups="addons"/>
<project name="odoo-business-spending-management-quebec-canada.git" path="addons/MathBenTech_odoo-business-spending-management-quebec-canada" remote="MathBenTech" revision="12.0_sale_order_line_timesheet_attribution" groups="addons,base"/>
<project name="odoo-cloud-platform.git" path="addons/camptocamp_odoo-cloud-platform" remote="camptocamp" revision="12.0_dev" groups="addons"/>

View file

@ -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}

25
script/restful/README.md Normal file
View file

@ -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
```

View file

@ -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)

View file

@ -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,,

1 url path revision clone-depth
131 https://github.com/ERPLibre/ERPLibre_image_db.git
132 https://github.com/odoo/design-themes.git addons
133 https://github.com/novacode-nl/odoo-formio.git addons
134 https://github.com/ajepe/odoo-addons.git addons