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

Using the Python debugger to trace method execution

Sometimes, application logs are not enough to figure out what is going wrong. Fortunately, we have the Python debugger available to us. This recipe shows how to insert a break point in a method and trace the execution by hand.

Getting ready

We will be reusing the export_stock_level() method shown in the two previous recipes. Be sure to have a copy at hand.

How to do it…

In order to trace the execution of export_stock_level() with pdb, follow the following steps:

  1. Edit the code of the method, and insert the line highlighted here:
    def export_stock_level(self, stock_location):
        import pdb; pdb.set_trace() products = self.with_context( location=stock_location.id ).search([]) fname = join(EXPORTS_DIR, 'stock_level.txt') ...

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