committed by
GitHub
10 changed files with 351 additions and 745 deletions
@ -1,257 +0,0 @@ |
|||
{ |
|||
"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": [] |
|||
} |
|||
] |
|||
} |
Binary file not shown.
@ -1,44 +0,0 @@ |
|||
# -*- coding:utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
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 |
@ -0,0 +1,32 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<data noupdate="1"> |
|||
|
|||
<record model="ir.module.category" id="module_category_rest_api_odoo"> |
|||
<field name="name">REST API</field> |
|||
<field name="description">Helps you manage your REST API records.</field> |
|||
<field name="sequence">17</field> |
|||
</record> |
|||
|
|||
<record id="group_rest_api_odoo_manager" model="res.groups"> |
|||
<field name="name">Manager</field> |
|||
<field name="category_id" |
|||
ref="rest_api_odoo.module_category_rest_api_odoo" /> |
|||
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]" /> |
|||
</record> |
|||
|
|||
<record id="base.default_user" model="res.users"> |
|||
<field name="groups_id" |
|||
eval="[(4,ref('rest_api_odoo.group_rest_api_odoo_manager'))]" /> |
|||
</record> |
|||
|
|||
<record id="rest_api_odoo_rule_manager" model="ir.rule"> |
|||
<field name="name">All REST APIs</field> |
|||
<field name="model_id" ref="model_connection_api" /> |
|||
<field name="domain_force">[(1,'=',1)]</field> |
|||
<field name="groups" |
|||
eval="[(4, ref('rest_api_odoo.group_rest_api_odoo_manager'))]" /> |
|||
</record> |
|||
|
|||
</data> |
|||
</odoo> |
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 116 KiB |
@ -1,18 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!-- Inherited user view for Adding API key. --> |
|||
<record id="view_users_form" model="ir.ui.view"> |
|||
<field name="name">view.users.form.inherit.rest.api.odoo</field> |
|||
<field name="inherit_id" ref="base.view_users_form"/> |
|||
<field name="model">res.users</field> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//page[@name='access_rights']" position="after"> |
|||
<page string="API" name="rest-api"> |
|||
<group> |
|||
<field name="api_key" groups="base.group_user"/> |
|||
</group> |
|||
</page> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
</odoo> |
Loading…
Reference in new issue