Overriding Plugin Method

Hello all!

I have been trying to create a hook to replace the functionality of an erpnext method, “calculate_taxes_and_totals”, found in “erpnext/erpnext/controllers/taxes_and_totals.calculate_taxes_and_totals”.

As far as I can see, the hook lists “override_whitelisted_methods” (to replace the method directly) and “override_doctype_class” (to replace the entire class) are only for core DocType classes, not those introduced by plugins.

I’d prefer to avoid monkey patching, as it seems to be used for a quick fix, not for permanent use.

Summary: How can I override a method in a plugin?

there is no harm to use monkey patch if you use it properly.
and for your scenario monkey patch is the solution.

1 Like

you can use this patching from hooks.

just add same import code in hooks and it will work.

Hello Yamen,

Just wanting to get some clarification on this message - is this some sort of intrinsic Frappe file that disallows coding faux pas, or is it a check people can run on installed plugins to make sure they behave?

I’m not sure what this message means as a whole.

Please go through this discussion