Unable to override core pyhton method

Hi all,
Can we override the core method which neither belong to doctype class nor whitelisted?

I tried to override by creating the patch in the custom app through hooks but it is effecting all the sites which is available in that bench, even though the custom app is not installed to that site.