-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow normal cusomtization workflow with multiple installed apps
- Loading branch information
1 parent
e055a03
commit 1001b75
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
import frappe | ||
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields | ||
from frappe.custom.doctype.property_setter.property_setter import make_property_setter | ||
|
||
def load_customizations(): | ||
customizations_directory = Path().cwd().parent / 'apps' / 'check_run' / 'check_run' / 'check_run' / 'custom' | ||
files = list(customizations_directory.glob('**/*.json')) | ||
for file in files: | ||
customizations = json.loads(Path(file).read_text()) | ||
for field in customizations.get('custom_fields'): | ||
existing_field = frappe.get_value('Custom Field', field.get('name')) | ||
custom_field = frappe.get_doc("Custom Field", field.get('name')) if existing_field else frappe.new_doc('Custom Field') | ||
field.pop('modified') | ||
{custom_field.set(key, value) for key, value in field.items()} | ||
custom_field.flags.ignore_permissions = True | ||
custom_field.flags.ignore_version = True | ||
custom_field.save() | ||
for prop in customizations.get('property_setters'): | ||
property_setter = frappe.get_doc({ | ||
"name": prop.get('name'), | ||
"doctype": "Property Setter", | ||
"doctype_or_field": prop.get('doctype_or_field'), | ||
"doc_type": prop.get('doc_type'), | ||
"field_name": prop.get('field_name'), | ||
"property": prop.get('property'), | ||
"value": prop.get('value'), | ||
"property_type": prop.get('property_type') | ||
}) | ||
property_setter.flags.ignore_permissions = True | ||
property_setter.insert() |