How to Use JSON- RPC in Odoo 17: A Step-by-Step Guide

March 20, 2025

How to Use JSON- RPC in Odoo 17: A Step-by-Step Guide

Uncategorized

Odoo 17 is a robust ERP system that supports smooth integration with external applications through different APIs. One of the most effective methods of communicating with Odoo programmatically is through JSON-RPC (JavaScript Object Notation – Remote Procedure Call). JSON-RPC is a light, stateless protocol that supports structured requests and responses between a client and a server.

In this in-depth guide, we will take you deep into the realm of RPC Odoo 17. We will describe what JSON-RPC is, why it is useful, and how to utilize JSON RPC in Odoo 17 in your Odoo projects. Additionally, we will walk through real-life implementation using correct Odoo 17 coding practices and provide a detailed example for better understanding.

Understanding JSON-RPC

JSON-RPC isΒ anΒ RPCΒ protocol encoded in JSON. ItΒ allowsΒ clients toΒ runΒ commands on a remote server withoutΒ theΒ needΒ for complicatedΒ setup or communication layers.Β AsΒ opposed toΒ REST APIs, whichΒ dependΒ onΒ pre-establishedΒ HTTP verbs (GET, POST, PUT, DELETE), JSON-RPCΒ employsΒ aΒ straightforwardΒ request-response model where all interactions areΒ containedΒ within JSON objects.

Example JSON-RPC Request


					
				

Example JSON-RPC Response


					
				

Why JSON-RPC?

JSON-RPC provides a number of benefits when implementing Odoo with external systems:

  1. Lightweight and Efficient: JSON-RPC is lightweight compared to XML-RPC.
  2. Uniform Structure: The format of JSON helps in easier debugging and reading.
  3. Batch Processing Supported: You can send many requests in a single call.
  4. Stateless Protocol: No session tracking is required, reducing complexity.
  5. Language Agnostic: Works with Python, JavaScript, PHP, and many other languages.
  6. Quicker Execution: As opposed to multiple requests of REST APIs, JSON-RPC achieves quicker execution with structured bulk requests.

Why JSON-RPC?

ActivatingΒ JSON-RPC in Odoo 17

You have to enable your Odoo instance’s support for remote API access first in order to be able to utilize JSON-RPC in Odoo 17. Enabling web service settings within the configuration file (odoo.conf) is needed to accomplish this.

Step 1: Enable JSON-RPC in Odoo Configuration

ModifyΒ the odoo.conf file andΒ addΒ the following lines:


					
				

Restart the Odoo server after making these changes.

Step 2: Implementing JSON-RPC in Odoo 17

Creating a JSON-RPC Endpoint in Odoo

We need to create a custom endpoint in Odoo that can be accessed via JSON-RPC. Here’s how you can create a controller to fetch sold products:

Python Controller Code


					
				

This controller defines an endpoint (/fetch_sold_products) that returns a JSON response containing sold product details.

Fetching Data via JSON-RPC in JavaScript

To fetch data using JSON-RPC in JavaScript, use the following Odoo module:

JavaScript Code


					
				

Rendering template code:


					
				

Real-Life Example

Suppose you operate an e-commerce site where you sell home appliances in your online store, and you want your website to dynamically display the 4 best-selling products. That is, instead of having to constantly update the product list manually, you can use JSON-RPC from the Odoo API. Now, every time a customer visits your site, the latest top-selling products are fetched automatically via JSON-RPC and displayed in real-time, improving accuracy and user experience.

Conclusion

JSON-RPC is a powerful and efficient protocol for interacting with the rpc Odoo 17. It provides a structured, lightweight, and scalable approach to performing CRUD operations, and automating processes. Using the proper implementation procedures, organizations can improve their integration capabilities and make data exchange between Odoo & third-party applications more seamless and efficient.

Additionally, through proper utilization of JSON-RPC, robust high-performing Odoo systems can be built integrating with third applications seamlessly.

Need Help? Get in touch

Frequently Asked Questions (FAQs)

What is JSON-RPC in Odoo 17?

Odoo 17 supports JSON-RPC, a remote procedure call protocol that provides JS (JavaScript) endpoints to allow external applications to use structured JSON requests and responses to communicate with Odoo.

How to use JSON-RPC in Odoo 17?

You can get started with JSON-RPC in Odoo 17 by enabling it in the odoo.conf configuration file, and then implementing various API endpoints by creating Odoo controllers that each respond to the JSON-RPC requests.

What are the benefits of using JSON-RPC in Odoo?

Communication with Odoo using JSON-RPC is faster and more performant, enabling batch requests and allowing the protocol to avoid the overhead involved with either REST or XML-RPC.

Is JSON-RPC better than REST API in Odoo?

Although JSON-RPC may provide a more performant and structured request format for multiple records or process batch jobs, REST API, because of more widespread usage, provides a richer set of endpoints and supports a more extensive set of HTTP request methods.

How do I debug JSON-RPC calls in Odoo?

If you want to debug API calls made to Odoo JSON-RPC, you can use standard logging mechanisms in Python, browser developer tools when issuing requests from JavaScript, or tools like Postman to test JSON-RPC API requests.

Recent Posts

Odoo 18 Implementation Services: What’s Included & Why It Matters?

Technology doesn't wait around for anybody, really. If your company still runs on antiquated technology,

Odoo Support Services for Small Businesses: Is It Worth It?

Managing even a small business is not a simple task. Everything must function perfectly, from

Avoid Costly Downtime: The Importance of Reliable Odoo Support

Imagine this: your company depends on professional Odoo assistance to keep the business functioning as

Odoo vs QuickBooks: Why Businesses Are Making the Switch

Running a firm depends mostly on managing its financial situation. Since QuickBooks is easy and

Related Blogs

Technology doesn't wait around for anybody, really. If your company still runs on antiquated technology, you are deliberately dragging yourself
Managing even a small business is not a simple task. Everything must function perfectly, from handling money to inventory and sales management
Imagine this: your company depends on professional Odoo assistance to keep the business functioning as it should. One day an unanticipated problem