ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Fixtures...don't know what it is


#1

As a user I’ve seen the word Fixtures as part of installation process of ERPNext but also as a command on some forms of the application itself. I asumme after some changes on forms “Fixtures”, will apply (fix) them…

Is this relevant and if yes, is there some documentation about?

Many thanks

Camilo Correa
Happy implementing ERPNext


#2

Fixtures are to migrate data / settings for new apps.

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

Edit: fixed link


#3

Thank you so much Rushabh!

Allways happy learnig more every day about ERPNext.
Camilo


#4

broken link, please can you proivide the new one?


#5

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


#6

thanks


#7

Link broken again!


#8

@aakvatech For your Reference:

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


#9

Have gone through the link posted, and I see a need to have a more step by step document for a newbie. Should I post what I experienced as a user right here or is there a more appropriate place to share steps as per my experience?


#10

Hi @aakvatech, it should be okay to post it here, I’ve found this thread through a simple search. And I think many others will find your experience useful if you’d be able to post it here. :slight_smile:


#11

Probably the most canonical way would be to fork the frappe repo and submit a pull request :building_construction:

https://github.com/frappe/frappe/blob/develop/frappe/docs/user/en/guides/app-development/how-to-create-custom-fields-during-app-installation.md


#12
  1. Create new app e.g. - bench get-app library_management
  2. Install new app into your site e.g. - bench --site erpnext.vm install-app library_management
  3. Customize your form and ensure that the module name is changed to your app name e.g. - library_management
  4. Open file hooks.py using a text editor, such as “vi” from the location e.g. - ~/frappe-bench/apps/library_management/library_management/hooks.py
  5. At the end of the hooks.py file you can add line
    fixtures = [“Custom Field”]
    I would also add other usual customizations such as “DocType”, “Custom Script”, “Property Setter”, “Print Format”.
    I can also use the same technique to add all setups that are done so that migrating setups from test to production and vice versa is easy.
  6. Run command “bench --site mysite export-fixtures” to export all mysite customizations where you have selected Module name as your app name e.g. - library_management. The *.json files will be stored in the location ~/frappe-bench/apps/library_management/library_management/fixtures.

I haven’t tried using github yet but have read that one could upload the changes on github, or as I did, you can download those json files and put it into another system that has the same app created, into the same fixtures folder and use bench --migrate to apply the customization onto those sites that has the application installed.

hth


Customization that require change in the code, and the upgrade
#13

Hello @avinash_upadhya28

This should be bench new-app library_management

This is not clear, can you please explain?
For example, I need to customize the Task doctype which is existed in erpnext application, so how to change the module name to be same as the created application name which is in your example is library_management?

You need to add DocType to be part of the fixtures that need to be exported because you need to include the changes that was made directly to the DocType and not through the Customize Form?

Regards
Bilal


#14

Yes, this could be required depending, whether you are getting ready app or making a new one.

Customizing a doctype form is recommended. Changing base doctype will break the updates and will require you to do bench update --reset that will undo all your work directly done on base doctypes. I have done this mistake too many a times already. Export the customized form to your “library_management” app.

Like above, better customize the form, and export form to your cutom app.


#15

Doctype of customized apps automatically get stored in the custom app/custom module/doctype directory and you have to git push it to your repository thereafter.


#16

Hello @aakvatech

Thanks a lot for your kindly reply and help.

How? Can u explain the steps?
Do you mean export the fixtures or something else?
Where to be exported at the “library_management” app? At which directory?

Regards
Bilal


#17
  1. Set the developer_mode to 1 on server

  2. Customize the form for the doctype:

  3. Select your custom app you created, in this example it’s called Recharge
    image

If you don’t have a custom export then you need to make a new one like you indicated earlier.

  1. You then run the command to export-fixtures:

if you have single site

bench export-fixtures

if you are multi-tenant

bench --site <> export-fixtures

  1. The file will be stored in the apps/recharge/recharge/recharge/custom/
    frappe@:~/frappe-bench$ ls apps/recharge/recharge/recharge/custom/
    journal_entry.json purchase_receipt_item.json sales_taxes_and_charges.json
    payment_entry.json purchase_receipt.json stock_entry_detail.json
    purchase_invoice_item.json sales_invoice_item.json
    purchase_invoice.json sales_invoice.json

hth