Override_doctype_class hook not working

I have used the override_doctype_class hook to override the Contract doctype class with my custom class but even after doing everything in the right way default Contract class is called not my CustomContract class.

Also, this hook is working on my local but not on the server.

Can anyone help me with this?

Hello,

In my hooks.py I have used the override_doctype_class hook but when I tried to run frappe.get_hooks(“override_doctype_class”) in the console it gives me an empty dictionary.

Did anyone face such an issue?

Attaching images for reference:

Hi,
I have the same problem with the doctypes, were you able to solve it?

Thanks!!

2 possible issues

  1. file path, make sure in your bench console your can import the class correctly.
    e.g
    from onefinance.onefinance.overrides.contract import CustomContract should run without errors.
    for me the correct path is onefinance.overrides.contract.CustomContract, here the overrides is the folder under the app, there is contract.py file which includes the CustomContract class python code

  2. the key in hooks is the doctype instead of the class, e.g if override Production Plan, then the key in hooks is Production Plan instead of ProductionPlan.

Hlo @szufisher,

from onefinance.onefinance.overrides.contract import CustomContract is running without error in console and key is also doctype name but I am facing the same issue.

also check whether the app is installed on the site, I made such mistake before.

Were you able to find a solution, facing the same thing, working locally, but when I ship to production, it doesn’t work?

Try bench migrate in production