Create a new field with an App - how-to wanted

  1. “Custom Field” is the Name of my Custom field, right? If it’s name Customer Number my line looks like hooks = "Customer Number" right?
  2. if I add another custom field later, will I have to add a new line of hooks = ["Custom Field"] (using the actual Name of that additional custom field) to the hooks.py and repeat the bench export-fixtures command, correct?

@vrms, “Custom Field” is the name of the table that do you want sync using an app, it will sync all custom fields at one time!

hi, once more!

seems something is not 100% working with bench export-fixtures

apparently there is no fixtures folder created inside of …

/home/frappe/frappe-bench/apps/my_app

the message I get in return of bench export-fixtures is …

exporting Web Form app erpnext filters None

(which doesn’t tell me much).

The ne app shows as installable on my current system. Also I can install it on a different system, but it doesn’t add the custom field created to that. What I did was

  • create a custom field (inside ERPNext GUI)
  • cd /home/frappe/frappe-bench
  • bench new-app [app_name]
  • echo ‘hooks = “Custom Field”’ >> /home/frappe/frappe-bench/apps/[app_name]/hooks.py
  • cd /home/frappe/frappe-bench
  • bench export-fixtures

Any suggestions?

@vrms edit the hooks.py manualy instead of use echo because it should be fixtures = ["Custom Field"]

sorry I had a mistake in my previous post. I meant fixtures = "Custom Field", not hooks = "Custom Field"

so no matter whether my hooks.py looks like

from future import unicode_literals

app_name = “ui_customizations”
app_title = “UI Customizations”
app_publisher = “vrms”
app_description = “Customizations for ERPNext”
app_icon = “octicon octicon-file-directory”
app_color = “red”
app_email = “myemaill@address.com
app_version = “0.0.1”
app_license = “MIT”
fixtures = “Custom Field”

or

from future import unicode_literals

app_name = “ui_customizations”
app_title = “UI Customizations”
app_publisher = “vrms”
app_description = “Customizations for ERPNext”
app_icon = “octicon octicon-file-directory”
app_color = “red”
app_email = “myemaill@address.com
app_version = “0.0.1”
app_license = “MIT”
fixtures = [“Custom Field”]

(difference being the brackets around “Custom Field”). There is no fixtures folder created inside of apps/[my_app_name] (neither any of it’s subfolders).

The message returned on bench export-fixtures always is
exporting Web Form app erpnext filters None

@vrms, can I confirm you have placed fixtures = ["Custom Field"] in your hooks.py file within your custom app folder?

Try running sudo supervisorctl reload after you have modified your hooks.py file then run bench export-fixtures from /home/frappe/frappe-bench.

Once done you should see the following result:

Exporting Web Form app erpnext filters None
Exporting Custom Field app my_app filters None

I tried it again … and again … and again. Then I found the trick.

you have to install the created custom app (using the App Installer) before running the bench export-fixtures command.

then the ‘fixtures’ folder is being created (and inside a json file. custom_file.json in my case. I guess that depends on what you have added to the hooks.py file)

I have not tested yet installing this app on a different system. Will report whether that works once executed successfully. thanks @max_morais_dmm & @bohlian so far

3 Likes

sorry to hijack the discussion @vrms @bohlian @max_morais_dmm , can you guys confirm the above procedure works on Production setup as well rather than Develop setup? I have only Production setup and has created custom field which i thought minor customisation without creating an custom app. The custom field survived last few bench update,but i guess i was lucky Argggh…

I guess to rectify this now i have to create custom app as per above procedure and remove the created custom field from mariaDB directly?

@Jay yes the procedure works in Production too, but with a Small difference, without an app, the modifications only will survive in the instance used to create it.

1 Like

thank you, i should start creating custom app

@Jay can you post the repo to your app once you are ready here List of Community made Apps please?

I wouldn’t be all too terribly surprised whether other’s might want to solve similar issue’s.

@vrms haha :grinning: sure will,but still a long way to go , i am stuck setting up local development machine here Turning a Mac into a Developer Machine based on Master branch without Installer - #5 by Jay

i get invalid syntax for

bench init frappe-bench --frappe-branch master

Hello team,

I have followed your procedure and successfully exported the customization to an app ui_customization. I can see my custom fields mentioned in the custom_fields file in fixtures folder in my new app.

I shifted bck to Master, then I tried installing the new app in another site through the UI. The app installer tells me that my app is installed, but I don’t see any customization reflected on the new site!

What should I do to get my customizations to work for the new site?

mentioning @vrms @bohlian and @max_morais_dmm, but really any support from anybody will be much appreciated.

This is my first app by the way!

Regards,
Ahmed

Just found how to! a simple bench update will do the trick. Writing it here in case somebody gets stuck in the same phase later on.

The app thing is great! I could now push custom field changes easily between sites, but is there something similar for script reports, custom scripts, and print formats?

Regards,
Ahmed

1 Like

hopping in this topic here again … what I still would like to find out is how you can do 1 App per customization (instead of having all customizations in 1 App).

The advantage of separating to have a a better overview by App name about what the App does, and also this would help a lot in sharing Customizations. I might have 15 Customizations but sharing all of them in 1 big App with might interfere with the Customizations someone else has done in their system already.

If it was possible to make a single App and call it Lucky Number for Employee or Customer’s Dog’s Birthday or so it, on the one hand, would be very clear what it precisely does and, on the other hand, would make it more easy to share it (because you share specific things and not a bundle of a million buttons from which someone else just might need 1 or 2).

I haven;t had time to look into this yet, so if anybody has the skills to do that … I (and maybe others) would be more then happy to read about it here I guess

Is there a video / document that shows step by step process with example. I tried finding it but couldn’t get it. I can help make one but need to learn all the steps first and make it.

Objective is to help me and others who get started with ERPNext on how to port customizations from development to production.

Would be great to also have some tips shared along that document on how to manage multiple company customizations separately.

You are aware of for eg these https://frappe.io/docs/user/

Developer Tutorial Videos

To manage your changes you best use a code repository for eg App Development using GitHub · frappe/frappe Wiki · GitHub

The web has many howto docs with best practices…

1 Like

This is good. I missed getting to this video, thinking it was only meant for separate app and not customize existing forms, reports, etc.

As somebody else has indicated that installing your custom app is the key and then you have to export the customizations / set the print formats to the module named after adding the custom app.

I am now fine with the knowledge, and understand this well.

1 Like

Thanks, this also helps a lot after you have gone through a few trials on your own.

Since Frappe and ERPNext are so interwoven and people who are used to it do not differentiate much, for newbies it does become daunting to see Frappe all the time and then get confused why is it inter-used. I guess this is part of learning about ERPNext.

Kudos to the great community support that is available.