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

Exporting Fixtures and Filter for Reports

customization

#1

Hello;

I need to set filter on the reports using fixtures, I used below line in hooks.py but it did gave me the below error:

Fixtures

fixtures = [{‘Report’, “filters”: [[“name”, “like”, (“Jewelry”)]]},‘Custom Field’, ‘Custom Script’, ‘Property Setter’]

The error when exporting the fixtures:

File “/home/frappe/frappe-bench/apps/jewelry/jewelry/hooks.py”, line 126
fixtures = [{‘Report’, “filters”: [[“name”, “like”, (“Jewelry”)]]},‘Custom Field’, ‘Custom Script’, ‘Property Setter’]
^
SyntaxError: invalid syntax

Can someone advise me on the right syntax to be written in the hooks.py.

Regards
Bilal


#2

The data structure is as follows:
fixtures is a list of dictionary_objects:

fixtures = [object1, object2, objectN]

Each dictionary_object with filters contains:

*dictionary_object* = { "doctype":"*doctype_name*", "filters":"*list_of_filters*" }

doctype is self-explanatory, it is the DocType name you wish to export.

Each list_of_filters contains itself, a list_of_filter_criteria
The list_or_filter_criteria itself is a list containing:

*fieldname*, *operator*, (*value*)

Note that value is a Tuple!

*list_of_filter_criteria* = ["fieldname", "operator", ("Value1","Value2","ValueN", )]

So that:
“filters”: [list_of_filter_criteria]

For your convenience, these are the allowed operators:

Side note: I stumbled upon the operators during a traceback while running bench export-fixtures by using “not” and this was the message returned:

Operator must be one of =, !=, >, <, >=, <=, like, not like, in, not in, between, descendants of, ancestors of, not descendants of, not ancestors of, is```