Profiling Python code
Sometimes, you will be unable to pinpoint the cause of an issue. This is especially true of performance issues. Odoo provides some built-in profiling tools that help you find the real cause of an issue.
How to do it...
Perform the following steps to do this recipe:
- Odoo's profiler is available at
odoo/tools/profiler.py
. In order to use the profiler in your code, import it into the file:from odoo.tools.profiler import profile
- After importing it, you can use the
profile
decorator on the methods. To profile a particular method, you need to add theprofile
decorator to it. Take a look at the following example. We put theprofile
decorator in themake_available
method:@profile def make_available(self): if self.state != 'lost': self.write({'state': 'available...