Export Fixtures for doctype

I have created a custom app and in hooks.py i used fixtures = [‘Custom Field’,‘Sales Invoice’] , where Sales Invoice is a DocType .
In fixtures folder 2 files are generated namely custom_field.json and sales_invoice.json.

custom_field.json is having json data but sales_invoice.json is empty. why ?

I am unable to generate json data for Sales Invoice Doctype in Fixtures folder.

in hooks.py

fixtures = [
    {"dt": "DocType", "filters": [
        [
            "name", "in", [
                "Doctype1Name",
                "Doctype2Name"
            ]
        ]
    ]},
    {"dt": "Custom Field", "filters": [
        [
            "name", "in", [
                "CustomFieldName"
            ]
        ]
    ]}
]

then run command
bench export-fixtures

7 Likes

Its working, a doctype.json file with json data is generated in fixtures folder

Thank you Sayed

Hey Sayed,

I have to export 4-5 doctypes , in these 4-5 doctypes there will multiple custom fields , so is it required to specify all custom_fields name using filters like

{“dt”: “Custom Field”, “filters”: [
[
“name”, “in”, [
“CustomField1Name”,
“CustomField2Name”,
“CustomField3Name”

        ]
    ]
]}   //I have tried this and all multiple  custom fields are generated in json file and i got all custom fields 1,2,3

Is there is any optimization instead of adding all multiple custom_fields names in filters (in some scenario if 100 custom fields are there then i have to add those 100 fields one by one )

any optimization ?

1 Like

Try to use a different operator.

For example, “like”.

 {"dt": "Custom Field", "filters": [
         [
             "name", "like", "Sales Invoice-%"
         ]
 ]}

The previous code should export all custom fields starting with “Sales Invoice-”.

5 Likes