Commit Graph
6 Commits
Author SHA1 Message Date
fw-bot fd06a7fe14 [FIX] profiler: be more pesimistic
The profiler was too optimistic. If the local variable self was not a
cursor, it assumed it was automatically an Odoo model.
Instead, only do the custom tracer methods when self is an instance of
BaseModel.

Full scenario to reproduce explained at odoo/odoo#39237

In case a method like the default_get of utm.mixing was profiled, the
tracer crashed when evaluating `__bool__(request)`.
The tracer considered self as an Odoo model while it was a werkzeug
instance with its custom __getattr__ that crashed while trying to
retrieve the content of `_name`.

Fixes odoo/odoo#39237

closes odoo/odoo#39524

X-original-commit: c8fa8fb067dcfb15330acde35d66ac41a255f669
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-10-29 15:57:20 +00:00
Adrian Torres 4b38cc6590 [REM] *: calls to @api.multi
Multi is the default api for methods, it is not necessary to explicitly
decorate methods with it, adds clutter and most people use it because
they see that the rest of the code uses it.

Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
2019-07-17 14:13:12 +02:00
Martin Trigaux e2bd3e328a [IMP] odoo: remove LazyCursor
Was specifically created for decimal.precision at f0646cb51b
Should no longer be needed
2019-07-03 11:16:24 +00:00
Christophe Matthieu b04bf31e29 [FIX] odoo profiler: Calculation error for loops
The previous line in a loop calculates the number of queries made until
the end of the loop. This causes the number of queries to be counted
twice.
Don't blacklist the entry point method.
Check the methods called from a blacklisted method.
2017-08-09 14:05:07 +02:00
Christophe Simonis 2b7179380a [FIX] tools: avoid defining unused variable using python2 only syntax 2017-08-07 15:02:56 +02:00
Christophe Matthieu 8fa7c68ca8 [IMP] tools: add a profiler for odoo performance analysis
Use ``profile`` to decorate an entry point method.
If ``profile`` is used without params, log as shallow mode else log
all methods for all odoo models by applying the optional filters.

:param whitelist: None or list of model names to display in the log
                 (Default: None)
:type whitelist: list or None
:param files: None or list of filenames to display in the log
                (Default: None)
:type files: list or None
:param list blacklist: list model names to remove from the log
                (Default: remove non odoo model from the log: [None])
:param int minimum_time: minimum time (ms) to display a method
                (Default: 0)
:param int minimum_queries: minimum sql queries to display a method
                (Default: 0)

.. code-block:: python

  from odoo.tools.profiler import profile

  class SaleOrder(models.Model):
    ...

    @api.model
    @profile                    # log only this create method
    def create(self, vals):
    ...
    @api.multi
    @profile()                  # log all methods for all odoo models
    def unlink(self):
    ...
    @profile(whitelist=['sale.order', 'ir.model.data'])
    def action_quotation_send(self):
    ...
    @profile(files=['/home/openerp/odoo/odoo/addons/sale/models/sale.py'])
    def write(self):
    ...

NB: The use of the profiler modifies the execution time
2017-07-26 15:02:59 +02:00