From a5a0d3cc5d10ea4608000d2a8c970105bf582a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s=20L=C3=B3pez?= Date: Fri, 12 Oct 2018 22:21:02 -0500 Subject: [PATCH] [REF] Add patch to kw fc --- profiler/hooks.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/profiler/hooks.py b/profiler/hooks.py index 33408ff93..f8fbce7d5 100644 --- a/profiler/hooks.py +++ b/profiler/hooks.py @@ -1,8 +1,9 @@ import logging -from openerp.http import WebRequest -from openerp.sql_db import Cursor +from odoo.http import WebRequest +from odoo.sql_db import Cursor +from odoo import api from .models.profiler_profile import ProfilerProfile @@ -27,6 +28,16 @@ def patch_web_request_call_function(): WebRequest._call_function = webreq_f +def patch_call_kw_function(): + _logger.info('Patching odoo.api.call_kw') + call_kw_f_origin = api.call_kw + + def call_kw_f(*args, **kwargs): + with ProfilerProfile.profiling(): + return call_kw_f_origin(*args, **kwargs) + api.call_kw = call_kw_f + + def patch_cursor_init(): _logger.info('Patching sql_dp.Cursor.__init__') cursor_f_origin = Cursor.__init__ @@ -42,4 +53,5 @@ def patch_cursor_init(): def post_load(): patch_web_request_call_function() + patch_call_kw_function() patch_cursor_init()