Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Custom fields order error in fixtures #7806

merged 3 commits into from Jul 4, 2019


Copy link

Don-Leopardo commented Jul 1, 2019


Sometimes, when you have a custom app with some custom fields, the customized doctypes (the ones with custom fields) start to mess up the order of the fields.


The reason for this to happen is that, in the custom_fields.json file, there are fields that have an insert_after referring to a field that is after them in the file. This means that at the moment that the first field is created in the DB, the reference of the insert_after does not exists so it puts 0 as the field's idx and that messes up the order of the fields in the doctype.

Steps to recreate:

We are going to need a clean site (frappe + erpnext only) and a clean app (a new app with nothing in it).

  • Install the new app in the clean site
  • Go to company and then customize the doctype like in the image below. Click on "update" after adding each field, this is to simulate an "addition in differents dates".
  • Add the Company doctype to the hooks of the app:
fixtures = [
        "dt": "Custom Field",
        "filters": [["dt", "in", ("Company")]]
  • Export fixtures of the site (bench --site SITE_NAME export-fixtures)
  • Delete your new fields from the tabCustom Fields in the DB to simulate a new installation
  • Migrate the site (bench --site SITE_NAME migrate)
  • If the bug was correctly recreated the fields should not be in order, like here:
    After migrate


I changed the export_fixtures function in to order the fields by idx and creation (this last order is to maintain the order of the doctypes that do not have different idx per entry).


This comment has been minimized.

Copy link

surajshetty3416 commented Jul 4, 2019

@Don-Leopardo can you please raise the PR for develop branch as well.


This comment has been minimized.

Copy link
Contributor Author

Don-Leopardo commented Jul 4, 2019

@surajshetty3416 there you go #7836

@surajshetty3416 surajshetty3416 merged commit d0ad9ce into frappe:hotfix Jul 4, 2019
6 checks passed
6 checks passed
Codacy/PR Quality Review Up to standards. A positive pull request.
Semantic Pull Request ready to be squashed
continuous-integration/travis-ci/pr The Travis CI build passed
coverage/coveralls Coverage decreased (-0.03%) to 45.845%
security/snyk - package.json (frappe) No manifest changes detected
security/snyk - requirements.txt (frappe) No manifest changes detected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.