How to do it...

What makes debugging client-side script difficult is that the web client heavily relies on jQuery’s asynchronous events. Given that breakpoints halt execution, the chance is high that a bug caused by timing issues will not occur when debugging. We’ll discuss some strategies for this later:

  1. Turn on debug mode with assets. For details, consult the Activating the Odoo developer tools recipe from Chapter 1, Installing the Odoo Development Environment.
  2. In the JavaScript function you’re interested in, call the debugger:
debugger;
  1. If you have timing problems, log to the console in some JavaScript function:
console.log(“I’m in function X currently”);
  1. If you want to debug during template rendering, call the debugger from QWeb:
<t t-debug=““ />
  1. You can also have QWeb log to the console by saying the following:
<t t-log=“myvalue” />

All of this relies on your browser offering appropriate functionality for debugging. While all the major browsers do that, we’ll only look at Chromium here for demonstration purposes. To be able to use the debug tools, open them by clicking on the top-right menu button and selecting More tools | Developer tools:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.130.201