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:
- Require the
data
andmodel
packages instatic/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 = require('web.form_common');
- Delete the hard-coded list in
init
to have it only set up the event listener:init: function() { var result...