Thursday, February 4, 2021

get caller function in odoo

 

 
    Let us say that we built a function in odoo and we want to get data of any function call this function , such as we want to make logging for any caller function fo our function , so we want to get

caller function name
caller function file
calling line in the caller function


and put all of these data in logging file , we can get all of these data as bellow

caller function name :

caller_function = sys._getframe(1).f_code.co_name

 

caller function file :

caller_filename = sys._getframe(1).f_code.co_filename 


calling line in the caller function :

caller_line_number = sys._getframe(1).f_lineno


#Note
we can get the current function name as
current_function = sys._getframe(1).f_code.co_name

and we can add them to logging file from here

No comments:

Post a Comment

Odoo Invoice Qr code issues

There are two main issues must of us facing with the QR code in Odoo invoice & these issues are 1/ QR code displayed as broken image w...