26.58

v 8.0 v 9.0 v 10.0 v 11.0 v 12.0 Third Party 31
Availability
Odoo Online
Odoo.sh
On Premise
Technical Name odoo_rest_api
Versions 9.0 8.0 10.0 12.0 11.0
You bought this module and need support? Click here!
Availability
Odoo Online
Odoo.sh
On Premise
Technical Name odoo_rest_api
Versions 9.0 8.0 10.0 12.0 11.0

Odoo Rest API

This module adds full support for Rest API in Odoo

FEATURES:

  • User can create, update, search, delete any record via Rest API
  • All python methods inside Odoo can be called from Rest Api
  • Works with every Odoo model and custom modules
  • Send context via rest api (e.g. language)
  • Operations on multiple records with one request
  • Authentication with Odoo login and password
  • Permissions based on Odoo user permissions
  • No additional python modules or software required - works on default Odoo
  • Test server and support: support@gksoftware.pl
  • POSSIBLE REQUESTS:

  • GET: /rest/<model> - get records from selected model; parameters: fields, offset, limit, domain, sort
  • GET: /rest/<model>/<ids> - get selected records from selected model; parameters: fields
  • POST: /rest/<model> - create record in selected model
  • PUT: /rest/<model>/<ids> - update selected records in selected model
  • DELETE: /rest/<model>/<ids> - delete selected records from selected model
  • POST: /rest/<model>/<method> - run any method from selected model
  • POST: /rest/<model>/<method>/<ids> - run any method from selected model for selected records
  • EXAMPLES:

    [Example 1] - Get all users data - selected fields

    Request:
    curl -X GET -u admin:admin -H "Content-Type: text/html" http://localhost:8069/rest/res.users -d "{'fields': ['name', 'login']}"
    Response
    [
      {
        "id": 1,
        "login": "admin",
        "name": "Administrator"
      },
      {
        "id": 6,
        "login": "portal",
        "name": "Demo Portal User"
      },
      {
        "id": 5,
        "login": "demo",
        "name": "Demo User"
      },
      {
        "id": 7,
        "login": "support@gksoftware.pl",
        "name": "Grzegorz"
      }
    ]

    [Example 2] - Search users: name contains 'demo'

    Request:
    curl -X GET -u admin:admin -H "Content-Type: text/html" http://localhost:8069/rest/res.users -d "{'domain': [['name', 'ilike', 'demo']], 'fields': ['name']}"
    Response
    [
      {
        "id": 6,
        "name": "Demo Portal User"
      },
      {
        "id": 5,
        "name": "Demo User"
      }
    ]

    [Example 3] - Get partners - selected ids

    Request:
    curl -X GET -u admin:admin -H "Content-Type: text/html" http://localhost:8069/rest/res.partner/25,26 -d "{'fields': ['name']}"
    Response
    [
      {
        "id": 25,
        "name": "Chao Wang"
      },
      {
        "id": 26,
        "name": "David Simpson"
      }
    ]

    [Example 4] - Create record

    Request:
    curl -X POST -u admin:admin -H "Content-Type: text/html" http://localhost:8069/rest/res.partner -d "{'name': 'Created Partner'}"
    Response
    46

    [Example 5] - Update 3 records with one request

    Request:
    curl -X PUT -u admin:admin -H "Content-Type: text/html" http://localhost:8069/rest/res.partner/25,26,46 -d "{'name': 'New name'}"
    Response
    true

    [Example 6] - Delete selected records

    Request:
    curl -X DELETE -u admin:admin -H "Content-Type: text/html" http://localhost:8069/rest/res.partner/26,46
    Response
    true

    [Example 7] - Execute model method - confirm sale order

    Request:
    curl -X POST -u admin:admin -H "Content-Type: text/html" http://localhost:8069/rest/sale.order/action_confirm/3
    Response
    true
    Any questions?
    Want to test this module?
    Email me: support@gksoftware.pl

    Please log in to comment on this module

    • The author can leave a single reply to each comment.
    • This section is meant to ask simple questions or leave a rating. Every report of a problem experienced while using the module should be addressed to the author directly (refer to the following point).
    • If you want to start a discussion with the author or have a question related to your purchase, please use the support page.
    There are no ratings yet!
    More info
    by
    David Welch
    on 3/18/19, 11:38 AM Confirmed Purchase

    Just noticed my post yesterday was under the v9 release, but, I'm running v11, using the v11 Rest code.


    Request on post scrambled
    by
    David Welch
    on 3/17/19, 11:36 PM Confirmed Purchase

    Here's the POST without html in the body field, which was scrambled when in previous: {'body':'Here’s my picture', 'model':'mail.channel', 'res_id':22, 'message_type':'comment', 'subtype_id':1, 'attachment_ids':[4503]}


    Update does not work on many2many field
    by
    David Welch
    on 3/17/19, 11:33 PM Confirmed Purchase

    I have a very basic update on mail.message using: curl -X POST -u admin:*** -H "Content-Type: text/html" http://dev.myserver.com:8010/rest/mail.message -d "{'body':'

    Here’s my picture

    ','model':'mail.channel','res_id':22,'message_type':'comment','subtype_id':1,'attachment_ids':[4503]}" and all fields update, except attachment_ids value, which is a many2many field. The value of 4503 is valid on the ir_attachment and has values of res_model="mail.channel" and res_id=22, matching the keys in the above. I have tried many formats for the attachment_ids field value, but, nothing works. How do I update this field using your api? Thanks!