In the evolving landscape of Odoo 17 development, mastering JSON-RPC in Odoo is no longer optional—it’s essential. As traditional methods like rpc.query
and ajax.jsonrpc
fade out, developers must adapt to smarter, more efficient tools. JSON-RPC offers the flexibility, speed, and structure modern Odoo apps demand.
In this guide, we’ll break down how it works, why it matters, and how you can use it to build faster, cleaner, and more reliable solutions with confidence.
Table of Contents
What Is JSON-RPC and Why It Matters in Odoo 17?
JSON-RPC is the modern heartbeat of remote calls in Odoo 17. It replaces outdated methods like XML-RPC and ajax.jsonRPC with a cleaner, faster, and more standardized way to communicate between the frontend and backend. Whether you’re building custom modules or optimizing website interactions, JSON-RPC gives you precision and performance.
From POS interactions to dynamic dashboards, developers are turning to JSON-RPC for seamless, scalable integrations that just work—fast.
Role of JSON-RPC in Odoo 17 Architecture
JSON-RPC plays a pivotal role in the modern Odoo 17 architecture, streamlining communication between the frontend and backend. It seamlessly integrates with Odoo’s client-server model, ensuring faster, more reliable data transactions.
With Odoo 17, legacy methods like rpc.query
and ajax.jsonrpc
are officially deprecated. In their place, the new @web/core/network/rpc_service
takes over, offering cleaner syntax, better error handling, and improved maintainability. Whether you’re building dynamic dashboards or handling custom endpoints, JSON-RPC is now the go-to choice for scalable, modern development in Odoo.
Pre-requisites & Configurations:
To get started with JSON-RPC in Odoo 17, you’ll need to ensure you’re set up for success. Here’s what you’ll need:
- Enable Developer Mode: Unlock all the Odoo tools and settings for effective debugging.
- Required Files & Modules: Ensure that essential modules are installed for smooth JSON-RPC integration.
- Odoo 17 RPC Ecosystem Overview: Familiarize yourself with the new structure, including the updated RPC service and endpoints for efficient communication.
Setting up correctly will set the stage for building efficient, scalable solutions.
Core Concepts: JSON-RPC Mechanics in Odoo
Understanding JSON-RPC mechanics is crucial for effective integration in Odoo 17:
- Request & Response: Learn how data is sent and received with JSON-RPC, and explore real-world examples to clarify the process.
- Authentication & Routing: Set up secure and efficient pathways for your RPC calls with proper authentication.
- Error Handling: Master debugging techniques to troubleshoot issues swiftly and maintain smooth operation.
By mastering these concepts, you’ll be equipped to handle all aspects of JSON-RPC with confidence.
How to Integrate JSON-RPC with Odoo 17: Step By Step Guide:
Getting started with JSON-RPC in Odoo 17 requires understanding how the backend and frontend interact through controllers and templates. Below is a clear guide to help you implement JSON-RPC with code examples for both backend and frontend.
Backend Example: JSON-RPC Endpoint in Python
Start by defining your controller with @http.route
, using type='json'
to handle JSON-RPC calls:
from odoo import http
from odoo.http import request
class SnippetController(http.Controller):
@http.route('/get_total_sold', type='json', auth='public', website=True)
def get_total_product(self):
products = request.env['product.template'].sudo().search_read([], ['name', 'list_price', 'id'], limit=4)
return products
- Uses
request.env
to fetch product data auth='public'
for frontend access- Fully JSON-ready with minimal setup
Frontend Example: Calling JSON-RPC via JavaScript
Now call the backend method using jsonrpc
from Odoo’s new @web/core/network/rpc_service
:
/** @odoo-module **/
import publicWidget from '@web/legacy/js/public/public_widget';
import { jsonrpc } from "@web/core/network/rpc_service";
import { renderToElement } from "@web/core/utils/render";
publicWidget.registry.DynamicSnippets = publicWidget.Widget.extend({
selector: '.js_dynamic_snippet',
start: function () {
jsonrpc('/get_total_sold', {}).then((res) => {
if (res) {
this.$el.find("#total").html(renderToElement('snippet.dynamic_snippet_custom', { res }));
}
});
}
});
- Dynamically fetches data
- Renders HTML without page reload
- Built for OWL, but supports jQuery fallback
Rendering Template Example
Render the product data using a clean, responsive QWeb template:
/<templates>
<t t-name="snippet.dynamic_snippet_custom">
<div class="w3-green w3-hover-shadow">
<section>
<div class="list-group">
<div class="w3-card w3-dark-grey">
<t t-foreach="res" t-as="prod" t-key="prod.id">
<a class="list-group-item active">
<t t-out="prod.name" />: <t t-out="prod.list_price" />
</a>
</t>
</div>
</div>
</section>
</div>
</t>
</templates>
- Uses
t-foreach
for looping - Fully dynamic with safe variables
- Easy to customize and reuse
This full-stack example bridges backend logic and frontend UX, giving you a scalable, modern pattern to call RPC in JS, render data templates, and build dynamic Odoo features fast. Till you have any confusion about how to integrate it. Get Our Odoo Services
Common Pitfalls and How to Avoid Them:
Even experienced developers hit snags when working with JSON-RPC in Odoo 17. Here’s how to sidestep the most common ones:
- Incorrect Routing: Make sure your
@http.route
path is accurate, usestype='json'
, and matches the client call exactly. - JS Load Timing Issues: Load your widgets after the DOM is ready. Use
publicWidget
properly to avoid rendering hiccups. - Auth Mistakes: Forgetting
auth='public'
or misusingsudo()
can block access to your endpoint. - Scalability Tip: Keep your logic modular—separate controller logic from data processing for maintainable, future-proof code.
Real-World Example: Product Sales Snippet
Want to showcase your best-selling products dynamically on the homepage? With JSON-RPC in Odoo 17, it’s a breeze. This use case pulls the top 5 products directly from your database and renders them in real-time—no manual updates needed.
- Backend logic filters and fetches the top sellers using
request.env
. - Frontend calls the JSON-RPC endpoint and dynamically updates the snippet.
- Built with QWeb and OWL for a clean, responsive layout.
Perfect for increasing engagement and conversions with real-time, data-driven content.
Future-Proofing Your Code: What’s Next?
To stay ahead in Odoo development, embracing the rpc_service
module is key. It centralizes API calls in a clean, modular way—ideal for scaling and performance. As Odoo continues evolving, especially on the frontend with OWL, aligning your code with modern practices ensures fewer rewrites and better maintainability.
Future versions will rely more on declarative, component-driven UIs. By writing clean RPC integrations today, you’re building a future-ready codebase that adapts effortlessly to upcoming updates. Stay modern, stay scalable.
Conclusion:
JSON-RPC in Odoo 17 isn’t just a technical upgrade—it’s a game-changer for speed, security, and user experience. By shifting to this modern RPC approach, you unlock faster data handling, cleaner code, and more dynamic frontend interactions. It’s the future of Odoo development, built for flexibility and performance.
If you’re looking to implement JSON-RPC effectively or need expert support to future-proof your Odoo projects, our team at Infintrix Technologies is here to help. Let’s elevate your development workflow—efficiently and confidently.