Book Image

Odoo Development Cookbook

By : Holger Brunn, Alexandre Fayolle, Daniel Reis
Book Image

Odoo Development Cookbook

By: Holger Brunn, Alexandre Fayolle, Daniel Reis

Overview of this book

Odoo is a full-featured open source ERP with a focus on extensibility. The flexibility and sustainability of open source is also a key selling point of Odoo. It is built on a powerful framework for rapid application development, both for back-end applications and front-end websites. The book starts by covering Odoo installation and administration, and provides a gentle introduction to application development. It then dives deep into several of the areas that an experienced developer will need to use. You’ll learn implement business logic, adapt the UI, and extend existing features.
Table of Contents (23 chapters)
Odoo Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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 = require('web.form_common');
  2. Delete the hard-coded list in init to have it only set up the event listener:

            init: function()
            {
                var result = this._super.apply(this, arguments);
                this.on(...