Hi Frappe team.
As you know i made two apps, Base Vat and Jasper Erpnext Report. The problem is when i export fixtures (Custom Field) the fixtures of Jasper Erpnext Report get mix with fixtures of Base Vat and the other way around. So when i update my apps people get Custom Fields that they do not want. If they install only Base Vat then they get also the Custom Fields of Jasper. If we all made apps with fixtures then the problem propagates.
So, the solution in my view is simple:
just change the code in fixtures.py like this:
1 def export_fixtures():
2 """Export fixtures as JSON to `[app]/fixtures`"""
3 for app in frappe.get_installed_apps():
4 for fixture in frappe.get_hooks("fixtures", app_name=app):
5 filters = None
6 if isinstance(fixture, dict):
7 filters = fixture.get("filters")
8 fixture = fixture.get("dt")
9 print "Exporting {0} {1} {2}".format(fixture, app, filters)
10 if not os.path.exists(frappe.get_app_path(app, "fixtures")):
11 os.mkdir(frappe.get_app_path(app, "fixtures"))
12 export_json(fixture, frappe.get_app_path(app, "fixtures", frappe.scrub(fixture) + ".json"), filters=filters)
We only need to add lines 5, 6,7 and 8. And in line 12 in export_json
function pass argument filters
.
Then in hooks.py we only need to use the special filters if we want to.
If we want we only have to do in base_vat hooks.py:
fixtures = [
"Custom Script",
{"dt":"Custom Field", "filters": [["dt", "in", ("Customer", "Company")]]}
]
or in hooks.py of jasper_erpnext_report:
fixtures = [
{"dt":"Custom Field", "filters": {"dt": "File"}}
]
In this way we can export to fixtures of base_vat Customer and Company fixtures and for jasper fixtures of File.
Of course we can be more specific, like:
For Base Vat fixtures:
{"dt":"Custom Field", "filters": [["fieldname", "in", ("vies_vat_check", "validate_vat", "vat_or_nif ")]]}
For Jasper Erpnext:
{"dt":"Custom Field", "filters": {"fieldname": "attached_to_report_name"}}
Please considere my proposal.
Thanks.