Bench export-fixtures includes custom field added by erpnext patches

I created a brand new custom app.

Added the following line in hooks.py
Fixtures = [“Custom Field”]

Then run bench export-fixtures

I would expect nothing to be exported since I haven’t yet created any custom fields.

But I see a many fields being added to fixtures/custom_field.json
Ex: “Project-github_sync_id”, “Task-github_sync_id”, …

I understand those exists in my site database table ‘tabCustom Field’ because they were added by some erpnext patches.

Is there any issue that could arise from having those fields included in my custom app fixtures ?

If yes, how could I exclude those from the export and include only my own custom fields ?

I know there is a filters property, as used here: pos_bahrain/hooks.py at master · f-9t9it/pos_bahrain · GitHub

But I understand this requires me to specify every one of my own custom fields explicitly.

I was looking for some way to say: include only custom fields from my own custom app.

Is that possible ?

I somehow thought custom fields were linked to a particular module or an app, but I can’t find any fields in the table ‘tabCustom Field’ that would make this link.

So I guess using filters to specify each one of my own custom fields is the way to go.

This is a good question.

The documentation for fixtures describes the technique very simply - making it appear as though it will just simply work as expected without any further fuss, but makes no mention that bench export-fixtures will also bring in changes made by other apps. It would be helpful for the documentation to give a little more detail about this and if possible how to work around it.

Has anyone developed a set of filter criteria to exclude the fixtures typically exported due to changes made by the erpnext app, so that only one’s own changes get exported without having to add specific filters for them?

With fixtures = ["Custom Field"] in hooks.py then the extra records created in custom_field.json at the moment that aren’t added by me are:

"name": "Project-github_sync_id",
"name": "Task-github_sync_id",
"name": "Deleted Document-github_sync_id",
"name": "Item-hub_sync_id",
"name": "Deleted Document-hub_sync_id",
"name": "Print Settings-compact_item_print",
"name": "Print Settings-print_uom_after_quantity",
"name": "Address-tax_category",
"name": "Print Settings-print_taxes_with_zero_amount",
"name": "Address-is_your_company_address",
"name": "Contact-is_billing_contact",

The name field is the concatenation of dt + - + fieldname.

1 Like

You can define Custom Field Doctype specific in hooks.py like this

fixtures = [
    {"dt": "Custom Field", "filters": [
        [
            "dt", "in", [
                "Patient",
                "Healthcare Practitioner" ,
				"Healthcare Service Unit" ,
                "Practitioner Schedule",
                "Patient Appointment" ,
                "Practitioner Service Unit Schedule" ,
                "Patient Encounter" ,
                "Clinical Procedure",
                "Vital Signs",
                "Complaint",
                "Patient Relation"

            ]
        ]
    ]},

     {"dt": "Property Setter", "filters": [
        [
            "doc_type", "in", [
                "Patient",
                "Healthcare Practitioner" ,
				"Healthcare Service Unit" ,
                "Practitioner Schedule",
                "Practitioner Service Unit Schedule" ,
                "Patient Encounter" ,
                "Clinical Procedure",
                "Vital Signs",
                "Complaint",
                "Patient Relation"

            ]
        ]
    ]},
]
5 Likes

add code like this in hooks.py file and then run

bench export-fixtures --app APP_NAME
fixtures = [
    {"dt": "Custom Field", "filters": [
        [
            "name",
            "in",
            {
				"Sales Invoice-room_folio_reference",
				"Payment Entry-room_folio_reference"
			}
        ]
    ]},

]