What is the process for invoking JSON RPC in ODOO?

odoo.define('custom_appointment_module.appointment', function(require) {
    "use strict";

    var ajax = require('web.ajax');
    var core = require('web.core');

    $(document).ready(function() {
        $('#view_appointment').click(function(event){
            ajax.jsonRpc("/my-booking", 'call', {
            });

        })
    })
})
    @http.route(['/my-bookings'], type="json", auth="user",csrf=False,methods=['POST'], website=True)
    def appointment_handler(self, **post):

        appointments = request.env['consultation'].search([])
        values=({
            'appointments': appointments,

        })
        return request.render("custom_appointment_module.tmp_customer_form")

Answer №1

The error message you should be seeing is as follows:

AttributeError: 'JsonRequest' object does not have a 'render' attribute

When dealing with JSON-RPC 2, the request handler method returns the result as a JSON-RPC object and wraps it in a JSON-RPC Response.

The 'render' attribute is only accessible when using HttpRequest.

You are making the correct call using jsonRpc, so the problem likely lies within the request handler itself.

A similar example can be found in the website_gengo where the controller method is declared like this:

@http.route('/website/post_gengo_jobs', type='json', auth='user', website=True)
def post_gengo_jobs(self):
    request.env['base.gengo.translations']._sync_request(limit=GENGO_DEFAULT_LIMIT)
    return True

And then called using the following code:

ajax.jsonRpc('/website/post_gengo_jobs', 'call', {});  

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

React's UseEffect can cause an endless loop of renders, leading to the error message "Maximum update

My Cart component contains an array of Cards. Whenever a user removes a product from the cart, it is removed from both the local storage and the UI. import React, { useState, useEffect } from 'react'; import { Link } from 'react-router-dom&a ...

My Fullcalendar is displaying events for the upcoming month. How can I resolve this issue?

This is the start date for my event in the full calendar: start: new Date('2016', '02', '07', 00, 30) However, when loading the calendar, this event is displaying on March 7, 2016. How can I resolve this issue? ...

I am facing an issue with Recharts not occupying the full width in my Nextjs/Reactjs project. Despite setting it to 100% width, it does not behave as

I am currently working with Recharts in combination with Next.js and Tailwindcss. I decided to create my own barchart by copying a code snippet from Recharts, but encountered an issue where changing the height to aspect worked fine, however setting the wid ...

Tips for saving HTML code within a concealed field utilizing jQuery

What is the best way to store a string with HTML tags in a hidden field using jQuery? I am attempting to use this code, but it's not functioning as expected: var terms = $('#TermsAndCondition').val(); alert($('#hdnTerms').val( ...

What is the reason behind TypeScript's lack of support for exporting with decorators?

The issue regarding this problem was addressed on https://github.com/tc39/proposal-decorators/issues/69. Despite this discussion, TypeScript does not currently support it. The following code demonstrates the lack of support: export @deco() class a {}; H ...

Is it feasible to update the value of a FormArray within a FormGroup?

Hey there, I'm new to working with reactive forms and I have a question about updating a FormArray without using the get method. Typically, I would use something like this.editForm.get('ingredients'). However, I would like to use patchValue ...

The webpage fails to display Vue Bootstrap radio buttons in a filled state

Hey there! I've been working on a project using vuejs and bootstrap-vue-3. My goal is to allow users to print data about the company, so I created a print scss file for that purpose and added some styles. However, I'm facing an issue where the ra ...

Exploring Three.js raycasting in a non-full screen scenario

I've encountered some challenges with raycasting in three.js recently. The div element I'm using is not fullscreen, which I believe is causing issues with the raycast positioning that I'm struggling to resolve. let mouseVector = new THR ...

Is it feasible to determine the specific memory address of an Object in a program?

Is it possible in JavaScript to determine the memory location and memory usage of an object? Any assistance on this matter would be greatly appreciated. ...

Warning: React Element creation caution with flow-router integration

Whenever I incorporate the following code into my Meteor app: Home = FlowRouter.route("/", { name: "App", action(params) { ReactLayout.render(App); } }); An error message pops up in the Chrome console: Warning: React.createElement: type shoul ...

What methods are commonly used to calculate the bitsPerSecond rate for media recording?

Is there a specific formula that combines frames per second and resolution to determine the bits per second for video encoding? I'm struggling to figure out the appropriate values to use for specifying the bits per second for 720p, 1080p, and 4k video ...

Persistent hover effect for collapsible accordion panels when closing them

My simple accordion features a functionality where a class of .open is added to the title + content group when you open a panel for styling purposes. Everything works smoothly, but I've noticed on my phone that after clicking to close a panel, the hov ...

A guide on trimming content with v-if in Vue.js

Recently, I attempted to trim the response value within a Vue condition. I require this functionality to apply the condition when the value is null or empty. <li v-if="item[0].otrodl4.trim() == ''" class="progress-step"> ...

Tips for updating the color, background, and height of the particle background using react-tsparticles

Is it possible to customize color and background in react-tsparticles? Below is an example of a particle configuration file named particle-config.js const particlesConfig = { background: { color: { value: "#232741", }, posi ...

Retrieve the file by utilizing the HTML obtained from the AJAX request

Currently, I am attempting to accomplish the task of downloading a file on the same page utilizing HTML generated from an AJAX call. The AJAX call is structured as follows: $.ajax({ url: './x ...

Easier JavaScript for numerous HTML elements

I am an aspiring JavaScript learner seeking advice. Currently, I am working on a website that features numerous items with multiple images for each. I am utilizing JQuery to display a larger image when the user hovers over a thumbnail image. My query is ...

Encircling the most recently selected image with a border

I have successfully made some <img> elements act like <input type="radio"> buttons and now I want to visually indicate the user's selection by adding a border around the chosen image. My challenge is that there are multiple rows of images ...

Stop unwanted scrolling upwards by using jQuery ajax function $.load

I'm currently in the process of creating an ajax chat using jquery and php. Everything seems to be running smoothly except for one issue related to scrolling. Essentially, I've implemented a time-out function that automatically reloads the inner ...

The remove() function is failing to eliminate the element from all parent elements with the same class

I have a bunch of Wordpress posts. When the browser size is reduced to a certain point, I must relocate one specific element from each post to another element as per the design requirements. Here is the code I am using to iterate through each post and mov ...

Syntax Error: The function `loadReposFromCache(...).error` is not defined in this building

I'm currently attempting to utilize the SyntaxHighlighter v4 plugin, but I'm facing issues with the build process! While following the guidelines provided here, an error popped up: $ ./node_modules/gulp/bin/gulp.js setup-project [10:12:20] Requ ...