Filtering Fixtures

Need help here, I’m trying export some doctypes customizations with filters:

fixtures = [
                {"dt":"Custom Field", "Custom Script", "Property Setter",  "filters": [["dt", "in", ("Maintenance Visit", "Maintenance Visit Purpose", "Quotation", "Customer")]]}
]

bench export-fixtures gave me:

File "/home/ubuntu/frappe-bench/apps/ordem_servico/ordem_servico/hooks.py", line 35
    {"dt":"Custom Field", "Custom Script", "Property Setter",  "filters": [["dt", "in", ("Maintenance Visit", "Maintenance Visit Purpose", "Quotation", "Customer")]]}
                                         ^
SyntaxError: invalid syntax

Hi Leonardo,
I think you need separate the fixtures for each doctype, as following:
fixtures = [ {"dt":"Custom Field", "filters": [["dt", "in", ("Maintenance Visit", "Maintenance Visit Purpose", "Quotation", "Customer")]]}, {"dt":"Custom Script", "filters": [["dt", "in", ("Maintenance Visit", "Maintenance Visit Purpose", "Quotation", "Customer")]]}, {"dt":"Property Setter", "filters": [["doc_type", "in", ("Maintenance Visit", "Maintenance Visit Purpose", "Quotation", "Customer")]]}, ]

I thought about that too… let’s see if anyone else has a better solution, thanks for suggestion :wink:

1 Like

fixtures is a list of dicts and your dict is not valid. Try this:

fixtures = [
    {
        "dt": ("Custom Field", "Custom Script", "Property Setter"), 
        "filters": [["dt", "in", ("Maintenance Visit", "Maintenance Visit Purpose", "Quotation", "Customer")]]
    }
]
2 Likes

How do I get “status” : Active, Employees with filter in fixtures

Try this:

    {
        "dt": "Employee",
        "filters": [{"status": "Active"}]
    },

Shouldn’t it be

{
        "dt": "Employee",
        "filters": [["status", "=", "Active"]]
}

Or

{
        "dt": "Employee",
        "filters": {"status": "Active"}
}

?

2 Likes