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

Writing tests for client side code


The more code you have on the client side, the more it becomes a liability. For server side code, there's the well-entrenched unit tests, and for JavaScript, we have QUnit (https://qunitjs.com), which Odoo uses.

Getting ready

We'll add our tests to the addon developed in the previous recipes, so grab the code from the recipe Making RPC calls to the server and put it in a new module called ch15_r04.

How to do it...

We have to add our test file and make it known to the test mechanism in the appropriate template.

  1. Add the static/test/ch15_r04.js file:

    odoo.define_section('ch15_r04', ['ch15_r04'], function (test, mock) {
        test('FieldMany2OneButtons', function(assert, ch15_r04)
        {
  2. Create a minimal implementation of FieldManager:

            var fake_field_manager = {
                get_field_desc: function()
                {
                    return {
                        'relation': 'res.users',
                        'domain': [],
                    };
                },
             ...