O'Reilly logo

Odoo Development Cookbook by Daniel Reis, Alexandre Fayolle, Holger Brunn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Making RPC calls to the server

Sooner or later, your widget will need to look up some data from the server. This recipe shows you how to do that. We'll replace the hard coded list of users in the many2one_buttons widget with a list queried from the server, depending on the field's domain.

Getting ready

This recipe is just a modified version of the previous recipe, Using client side templates: QWeb code, so grab a copy of it and use it to create addon ch15_r03.

How to do it...

We just have to adapt some JavaScript code at the right places:

  1. Require the data and model packages in static/src/js/ch15_r03.js:
    odoo.define('ch15_r01', function(require) { var core = require('web.core'), data = require('web.data'), model = require('web.Model'), form_common = ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required