Try ERPNext Buy Support Partners Foundation

How to extend an exisiting DocType via an app

First of all, sorry for the wall of text. :smiley:

I am learning frappe app development right now and was wondering how to extend existing DocTypes, e.g. Sales Invoice, via a custom app.

There are two articles regarding this in frappe app development documentation, but I still do not get the whole thing or which method is right one or do they both have their place.

  1. First way is to “Customize Form” the DocType and then export the customization to a Module of an app.

https://frappe.io/docs/user/en/guides/app-development/exporting-customizations

I get that, but does it mean when I install the app on another instance those customizations will be applied to that instance? What about conflict with other apps that maybe customized the same DocType using the same DocField names etc.?

I also do not get the last sentence in that Documentation: When you do bench update or bench migrate these customizations will be synced to the app. What does it mean “synced to the app”. I would export the customization to the app anyway via the export function in customize Form. Why should it get synced? What exactly is getting synced to where?

  1. Then there is Create Custom Fields During App Installation

https://frappe.io/docs/user/en/guides/app-development/how-to-create-custom-fields-during-app-installation

It also says that once can add Custom Fields to DocTypes outside of your app when it is installed to a new site. To do this, add the new custom fields that your app requires, using the Frappe web application.

Do they mean modify the DocType directly? If yes, let’s say I open “Sales Invoice” DocType and add another DocField. Where can/is this field referenced to my custom app? It says one needs to add fixtures = [“Custom Field”] in hooks.py and then export those fixtures via bench command to the app.

All in all, what are fixtures exactly. Are they the custom DocFields one adds to the DocType? Or should I never change DocTypes not related to the app directly, but only via customize form as described in point 1?
Or does point 2 build on point 1?

Sorry for the wall of text, but I still do not grasp the process fully. Would be nice if someone could clarify a bit. Thanks.

bumping post. I have the same question

When you do customize form, add custom fields then it will apply to one site database…in other hand, modifying doctype directly will affect repo source json file means it will apply to all sites under same bench instance

It’s highly recommended to put all of your customizations under separate custom app and you can maintain and sync it to all sites where you install it.

Using fixture you can export custom fields, custom scripts, doctype records, property setters etc from one site to custom app. Then youcan migrate and sync it to sites where you install this custom app.

You have to walkthrough the docs…and look into frappe source codes to see how the things are done then you can try to build your own app…

2 Likes

These past discussions may help Customize form vs modifying doctype

1 Like