Browse Source

Nov 28 [UPDT] : Updated 'rest_api_odoo'

pull/301/merge
AjmalCybro 5 months ago
parent
commit
fd7401080d
  1. 2
      rest_api_odoo/__manifest__.py
  2. 6
      rest_api_odoo/doc/RELEASE_NOTES.md
  3. 28
      rest_api_odoo/models/connection_api.py
  4. 2
      rest_api_odoo/security/ir.model.access.csv
  5. 14
      rest_api_odoo/static/description/index.html
  6. 4
      rest_api_odoo/views/connection_api_views.xml

2
rest_api_odoo/__manifest__.py

@ -25,7 +25,7 @@
"summary": """This app helps to interact with odoo "summary": """This app helps to interact with odoo
backend with help of rest api requests""", backend with help of rest api requests""",
"category": "Tools", "category": "Tools",
"version": "16.0.1.0.0", "version": "16.0.1.0.1",
'author': 'Cybrosys Techno Solutions', 'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions', 'company': 'Cybrosys Techno Solutions',
'maintainer': 'Cybrosys Techno Solutions', 'maintainer': 'Cybrosys Techno Solutions',

6
rest_api_odoo/doc/RELEASE_NOTES.md

@ -3,3 +3,9 @@
#### 28.12.2023 #### 28.12.2023
#### Version 16.0.1.0.0 #### Version 16.0.1.0.0
- Initial Commit for Odoo REST API - Initial Commit for Odoo REST API
### 09.12.2024
### Version 16.0.1.0.1
### UPDT
- Bug Fix - Fixed the access issues.

28
rest_api_odoo/models/connection_api.py

@ -20,7 +20,8 @@
# #
############################################################################# #############################################################################
from odoo import fields, models from odoo import api, fields, models
from odoo.exceptions import AccessError
class ConnectionApi(models.Model): class ConnectionApi(models.Model):
@ -45,3 +46,28 @@ class ConnectionApi(models.Model):
is_delete = fields.Boolean(string='DELETE', is_delete = fields.Boolean(string='DELETE',
help="Select this to enable DELETE method " help="Select this to enable DELETE method "
"while sending requests.") "while sending requests.")
@api.onchange('model_id')
def _onchange_model_id(self):
for record in self:
if record.model_id:
model_name = record.model_id.model
print(model_name)
# Check permissions
try:
can_read = self.env[model_name].check_access_rights(
'read', raise_exception=False)
can_write = self.env[model_name].check_access_rights(
'write', raise_exception=False)
print(can_write,can_read)
# record.can_create = self.env[
# model_name].check_access_rights('create',
# raise_exception=False)
# record.can_unlink = self.env[
# model_name].check_access_rights('unlink',
# raise_exception=False)
except AccessError:
can_read = False
can_write = False
can_create = False
can_unlink = False

2
rest_api_odoo/security/ir.model.access.csv

@ -1,2 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink 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 access_connection_api,access.connection.api,model_connection_api,base.group_system,1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_connection_api access.connection.api model_connection_api base.group_system 1 1 1 1

14
rest_api_odoo/static/description/index.html

@ -253,7 +253,9 @@
you can you can
authenticate rest api. authenticate rest api.
</li> </li>
<li>First, extract the <b>zip</b> file. Then, you will obtain the JSON-format file, which you can directly import into <b>POSTMAN.</b></li> <li>First, extract the <b>zip</b> file. Then, you will obtain
the JSON-format file, which you can directly import into <b>POSTMAN.</b>
</li>
<li>The url format will be like this - <b>http://cybrosys:8016/odoo_connect</b> <li>The url format will be like this - <b>http://cybrosys:8016/odoo_connect</b>
Replace 'cybrosys:8016' with your localhost port number. Replace 'cybrosys:8016' with your localhost port number.
</li> </li>
@ -280,8 +282,9 @@
</h3> </h3>
<p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;"> <p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;">
<ul> <ul>
<li>After rest api authentication, we can create records in the <li>Once authenticated via the REST API, records can be created
rest api app. within the REST API application. <br/><b>Note:</b> Only
administrators have access to view the module.
</li> </li>
<li>Here we can choose the model, and also we can <li>Here we can choose the model, and also we can
choose the http methods. choose the http methods.
@ -379,9 +382,10 @@
<li>You have to provide the model and also the id or the record <li>You have to provide the model and also the id or the record
that you want to update. that you want to update.
</li> </li>
<li>You can use the Postman collection that we have provided and , you <li>You can use the Postman collection that we have provided and
, you
will be always have to send request with your login will be always have to send request with your login
credentials. Otherwise, it will be showing access denied. credentials. Otherwise, it will be showing access denied.
</li> </li>
<li>The format for sending PUT request will be like this - <b>http://cybrosys:8016/send_request?model=res.partner&Id=46.</b> <li>The format for sending PUT request will be like this - <b>http://cybrosys:8016/send_request?model=res.partner&Id=46.</b>
</li> </li>

4
rest_api_odoo/views/connection_api_views.xml

@ -38,7 +38,6 @@
</field> </field>
</record> </record>
<!-- Action for 'connection.api' model with Tree and form views. --> <!-- Action for 'connection.api' model with Tree and form views. -->
<record id="rest_api_root_action" model="ir.actions.act_window"> <record id="rest_api_root_action" model="ir.actions.act_window">
<field name="name">Rest API Records</field> <field name="name">Rest API Records</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
@ -51,8 +50,7 @@
</field> </field>
</record> </record>
<!-- Menu items for the REST API. --> <!-- Menu items for the REST API. -->
<menuitem id="rest_api_root" groups="base.group_system"
<menuitem id="rest_api_root"
name="Rest API" name="Rest API"
sequence="10" sequence="10"
web_icon="rest_api_odoo,static/description/icon.png"/> web_icon="rest_api_odoo,static/description/icon.png"/>

Loading…
Cancel
Save