diff --git a/rest_api_odoo/Postman Collections/Odoo REST Api.postman_collection.json b/rest_api_odoo/Postman Collections/Odoo REST Api.postman_collection.json new file mode 100644 index 000000000..f474d5311 --- /dev/null +++ b/rest_api_odoo/Postman Collections/Odoo REST Api.postman_collection.json @@ -0,0 +1,257 @@ +{ + "info": { + "_postman_id": "83d9071d-626d-41ed-9800-78570ed11a7c", + "name": "Odoo REST Api", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "28148668" + }, + "item": [ + { + "name": "Authentication", + "request": { + "method": "GET", + "header": [ + { + "key": "db", + "value": "sep_db", + "type": "text" + }, + { + "key": "login", + "value": "123", + "type": "text" + }, + { + "key": "password", + "value": "123", + "type": "text" + }, + { + "key": "", + "value": "", + "type": "text", + "disabled": true + } + ], + "url": { + "raw": "http://cybrosys:8016/odoo_connect", + "protocol": "http", + "host": [ + "cybrosys" + ], + "port": "8016", + "path": [ + "odoo_connect" + ] + } + }, + "response": [] + }, + { + "name": "GET records", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "login", + "value": "123", + "type": "text" + }, + { + "key": "password", + "value": "123", + "type": "text" + }, + { + "key": "api-key", + "value": "4314c30b-994e-435d-a493-50cb0d33e99d", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"fields\": [\"name\",\"product_id\"]\n \n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://cybrosys:8016/send_request?model=mrp.production&Id=10", + "protocol": "http", + "host": [ + "cybrosys" + ], + "port": "8016", + "path": [ + "send_request" + ], + "query": [ + { + "key": "model", + "value": "mrp.production" + }, + { + "key": "Id", + "value": "10" + } + ] + } + }, + "response": [] + }, + { + "name": "Create Records", + "request": { + "method": "POST", + "header": [ + { + "key": "login", + "value": "123", + "type": "text" + }, + { + "key": "password", + "value": "123", + "type": "text" + }, + { + "key": "api_key", + "value": "4314c30b-994e-435d-a493-50cb0d33e99d", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"fields\" :[\"name\",\"phone\"] ,\n \"values\": {\"name\": \"abc\",\n \"phone\":\"55962441552\"\n }\n\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://cybrosys:8016/send_request?model=res.partner", + "protocol": "http", + "host": [ + "cybrosys" + ], + "port": "8016", + "path": [ + "send_request" + ], + "query": [ + { + "key": "model", + "value": "res.partner" + } + ] + } + }, + "response": [] + }, + { + "name": "Update Records", + "request": { + "method": "PUT", + "header": [ + { + "key": "login", + "value": "123", + "type": "text" + }, + { + "key": "password", + "value": "123", + "type": "text" + }, + { + "key": "api-key", + "value": "d52cd3de-ad4c-49ab-a5cb-727940b8117a", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"fields\" :[\"name\",\"phone\"] ,\n \"values\": {\"name\": \"abc\",\n \"phone\":\"55962441552\"\n }\n\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://cybrosys:8016/send_request?model=res.partner&Id=48", + "protocol": "http", + "host": [ + "cybrosys" + ], + "port": "8016", + "path": [ + "send_request" + ], + "query": [ + { + "key": "model", + "value": "res.partner" + }, + { + "key": "Id", + "value": "48" + } + ] + } + }, + "response": [] + }, + { + "name": "Delete Records", + "request": { + "method": "DELETE", + "header": [ + { + "key": "login", + "value": "123", + "type": "text" + }, + { + "key": "password", + "value": "123", + "type": "text" + }, + { + "key": "api-key", + "value": "d52cd3de-ad4c-49ab-a5cb-727940b8117a", + "type": "text" + } + ], + "url": { + "raw": "http://cybrosys:8016/send_request?model=res.partner&Id=48", + "protocol": "http", + "host": [ + "cybrosys" + ], + "port": "8016", + "path": [ + "send_request" + ], + "query": [ + { + "key": "model", + "value": "res.partner" + }, + { + "key": "Id", + "value": "48" + } + ] + } + }, + "response": [] + } + ] +} \ No newline at end of file diff --git a/rest_api_odoo/__manifest__.py b/rest_api_odoo/__manifest__.py index d7cd5c3b6..6b4811e0f 100644 --- a/rest_api_odoo/__manifest__.py +++ b/rest_api_odoo/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################# { "name": "Odoo rest API", - "version": "18.0.1.0.0", + "version": "18.0.1.0.1", "category": "Tools", "summary": """This app helps to interact with odoo, backend with help of rest api requests""", diff --git a/rest_api_odoo/controllers/rest_api_odoo.py b/rest_api_odoo/controllers/rest_api_odoo.py index 7767e9353..040a561d1 100644 --- a/rest_api_odoo/controllers/rest_api_odoo.py +++ b/rest_api_odoo/controllers/rest_api_odoo.py @@ -86,7 +86,6 @@ class RestApi(http.Controller): for key, value in record.items(): if isinstance(value, (datetime, date)): record[key] = value.isoformat() - data = json.dumps({ 'records': partner_records }) @@ -98,6 +97,10 @@ class RestApi(http.Controller): domain=[], fields=fields ) + for record in partner_records: + for key, value in record.items(): + if isinstance(value, (datetime, date)): + record[key] = value.isoformat() data = json.dumps({ 'records': partner_records }) @@ -121,6 +124,10 @@ class RestApi(http.Controller): domain=[('id', '=', new_resource.id)], fields=fields ) + for record in partner_records: + for key, value in record.items(): + if isinstance(value, (datetime, date)): + record[key] = value.isoformat() new_data = json.dumps({'New resource': partner_records, }) datas.append(new_data) return request.make_response(data=datas) @@ -151,6 +158,10 @@ class RestApi(http.Controller): domain=[('id', '=', resource.id)], fields=fields ) + for record in partner_records: + for key, value in record.items(): + if isinstance(value, (datetime, date)): + record[key] = value.isoformat() new_data = json.dumps( {'Updated resource': partner_records, }) @@ -195,6 +206,7 @@ class RestApi(http.Controller): 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') diff --git a/rest_api_odoo/doc/RELEASE_NOTES.md b/rest_api_odoo/doc/RELEASE_NOTES.md index bd4042da0..62703bb17 100644 --- a/rest_api_odoo/doc/RELEASE_NOTES.md +++ b/rest_api_odoo/doc/RELEASE_NOTES.md @@ -3,3 +3,9 @@ #### 02.12.2024 #### Version 18.0.1.0.0 - Initial Commit for Odoo rest API + +## Module + +#### 12.07.2025 +#### Version 18.0.1.0.1 + - Bug fixed related to data field data