In the evolving landscape of Odoo 17 development, mastering JSON-RPC in Odoo is no longer optional — it’s essential. As older methods like rpc.query and ajax.jsonrpc get phased out, developers need to move to the newer, more efficient tooling. JSON-RPC gives modern Odoo apps the flexibility, speed, and structure they need.
This guide breaks down how it works, why it matters, and how to use it to build faster, cleaner, more reliable solutions.
Table of Contents
- What Is JSON-RPC and Why It Matters in Odoo 17?
- Role of JSON-RPC in Odoo 17 Architecture
- Prerequisites & Configuration
- Core Concepts: JSON-RPC Mechanics in Odoo
- How to Integrate JSON-RPC with Odoo 17: Step-by-Step Guide
- Common Pitfalls and How to Avoid Them
- Real-World Example: Product Sales Snippet
- Future-Proofing Your Code: What’s Next?
- Conclusion
What Is JSON-RPC and Why It Matters in Odoo 17?
JSON-RPC is the modern backbone of remote calls in Odoo 17. It replaces older methods like XML-RPC and ajax.jsonrpc with a cleaner, faster, more standardized way for the frontend and backend to talk to each other. Whether you’re building custom modules or optimizing website interactions, JSON-RPC gives you more precision and better performance.
From POS interactions to dynamic dashboards, developers are reaching for JSON-RPC for integrations that are seamless, scalable, and fast.
Role of JSON-RPC in Odoo 17 Architecture
JSON-RPC plays a central role in Odoo 17’s architecture, streamlining communication between frontend and backend as part of Odoo’s client-server model.
As of Odoo 17, older methods like rpc.query and ajax.jsonrpc are deprecated. In their place, the new @web/core/network/rpc_service module takes over, with cleaner syntax, better error handling, and easier maintenance. Whether you’re building dynamic dashboards or custom endpoints, this is now the standard way to do RPC in Odoo.
Prerequisites & Configuration
Before building with JSON-RPC in Odoo 17, make sure you have:
- Developer Mode enabled — unlocks the tools and settings you’ll need for debugging.
- The right modules installed — confirm any modules your integration depends on are present.
- A working understanding of Odoo 17’s RPC ecosystem — the updated service and endpoint structure, specifically.
Getting this right up front saves you from debugging configuration issues disguised as code issues later.
Core Concepts: JSON-RPC Mechanics in Odoo
A few concepts matter more than the rest when you’re integrating JSON-RPC in Odoo 17:
- Request & response — how data actually moves between client and server.
- Authentication & routing — setting up secure, correctly-scoped paths for your RPC calls.
- Error handling — the debugging habits that get you to the actual problem faster.
How to Integrate JSON-RPC with Odoo 17: Step-by-Step Guide
Getting JSON-RPC working means understanding how the backend and frontend interact through controllers and templates. Here’s the full pattern, backend to frontend.
Backend Example: JSON-RPC Endpoint in Python
Define a 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.envto fetch product data. auth='public'makes it reachable from the frontend.- Returns data that’s already JSON-ready, with minimal setup.
Frontend Example: Calling JSON-RPC via JavaScript
Call the backend method using jsonrpc from Odoo’s @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 }));
}
});
}
});
- Fetches data dynamically, no page reload.
- Renders straight to HTML.
- Built for OWL, with a jQuery fallback where needed.
Rendering Template Example
Render the product data with a clean 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>
t-foreachhandles the loop.- Fully dynamic, with safely-escaped output via
t-out. - Easy to adapt for a different data shape.
Together, this bridges backend logic and frontend UX — a scalable pattern for calling RPC from JS, rendering templates, and shipping dynamic Odoo features quickly. If you get stuck wiring this up, our Odoo services team can help.
Common Pitfalls and How to Avoid Them
Even experienced developers hit the same handful of snags with JSON-RPC in Odoo 17:
- Incorrect routing — confirm your
@http.routepath is exact, usestype='json', and matches the client call precisely. - JS load timing issues — load widgets only after the DOM is ready; use
publicWidgetcorrectly to avoid rendering glitches. - Auth mistakes — forgetting
auth='public', or misusingsudo(), can silently block access to your endpoint. - Scalability — keep controller logic and data processing separate; it’s what keeps the code maintainable six months from now.
Real-World Example: Product Sales Snippet
Want to show your best-selling products dynamically on the homepage? JSON-RPC makes this straightforward — pull the top sellers from the database and render them in real time, with no manual updates needed.
- Backend logic filters and fetches top sellers using
request.env. - Frontend calls the JSON-RPC endpoint and updates the snippet dynamically.
- Built with QWeb and OWL for a clean, responsive layout.
A solid option when you want real-time, data-driven content without a lot of extra engineering.
Future-Proofing Your Code: What’s Next?
Staying current in Odoo development means embracing rpc_service now rather than later — it centralizes API calls in a clean, modular way built for scale. As Odoo’s frontend keeps evolving around OWL, code that already follows modern RPC patterns needs far fewer rewrites down the line.
Future versions will lean further into declarative, component-driven UIs. Writing clean RPC integrations today is what keeps your codebase adapting to that instead of fighting it.
Conclusion
JSON-RPC in Odoo 17 isn’t just a technical upgrade — it’s a real shift in speed, security, and user experience. Moving to this pattern gets you faster data handling, cleaner code, and more dynamic frontend interactions, and it’s where Odoo development is headed.
If you’d like help implementing JSON-RPC properly, or want your Odoo project future-proofed by people who do this regularly, Infintrix Technologies is here to help.


Comments
Start the conversation — be the first to share your thoughts.