Overriding Page Controllers

Hi Frappe Team!

This is a small contribution. A little while back I was trying to override existing page controller(context) on erpnext and found that only template files were allowed to be overwritten.

I’ve implemented a simple hook which allow overriding existing page controllers while inheriting the work the controller does:

ex:

extend_controller_context = [ “erpnext.templates.pages.cart”: “mymodule.templates.pages.cart” ]

The above lets “erpnext.template.pages.cart” run and passes the context to “mymodule.templates.pages.cart” to extend the cart page with extra content for the template.

I’ve made a pull request here: Inherit and Override Page Context by DeveloperMetal · Pull Request #2074 · frappe/frappe · GitHub

2 Likes

Check comments!