Skip to content

Commit

Permalink
feat: allow normal cusomtization workflow with multiple installed apps
Browse files Browse the repository at this point in the history
  • Loading branch information
agritheory committed Jul 3, 2022
1 parent e055a03 commit 1001b75
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions check_run/customize.py
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()

0 comments on commit 1001b75

Please sign in to comment.