feat: add option to apply module export filter in export_customizations function
This commit is contained in:
parent
39b523ea96
commit
4a538339a5
1 changed files with 20 additions and 4 deletions
|
|
@ -53,21 +53,35 @@ def get_doc_module(module: str, doctype: str, name: str) -> "ModuleType":
|
|||
|
||||
@frappe.whitelist()
|
||||
def export_customizations(
|
||||
module: str, doctype: str, sync_on_migrate: bool = False, with_permissions: bool = False
|
||||
module: str,
|
||||
doctype: str,
|
||||
sync_on_migrate: bool = False,
|
||||
with_permissions: bool = False,
|
||||
apply_module_export_filter: bool = False,
|
||||
):
|
||||
"""Export Custom Field and Property Setter for the current document to the app folder.
|
||||
This will be synced with bench migrate"""
|
||||
|
||||
sync_on_migrate = cint(sync_on_migrate)
|
||||
with_permissions = cint(with_permissions)
|
||||
apply_module_export_filter = cint(apply_module_export_filter)
|
||||
module_export_filter = module if apply_module_export_filter else ""
|
||||
|
||||
if not frappe.conf.developer_mode:
|
||||
frappe.throw(_("Only allowed to export customizations in developer mode"))
|
||||
|
||||
custom = {
|
||||
"custom_fields": frappe.get_all("Custom Field", fields="*", filters={"dt": doctype}, order_by="name"),
|
||||
"custom_fields": frappe.get_all(
|
||||
"Custom Field",
|
||||
fields="*",
|
||||
filters={"dt": doctype, "module": module_export_filter},
|
||||
order_by="name",
|
||||
),
|
||||
"property_setters": frappe.get_all(
|
||||
"Property Setter", fields="*", filters={"doc_type": doctype}, order_by="name"
|
||||
"Property Setter",
|
||||
fields="*",
|
||||
filters={"doc_type": doctype, "module": module_export_filter},
|
||||
order_by="name",
|
||||
),
|
||||
"custom_perms": [],
|
||||
"links": frappe.get_all("DocType Link", fields="*", filters={"parent": doctype}, order_by="name"),
|
||||
|
|
@ -82,7 +96,9 @@ def export_customizations(
|
|||
|
||||
# also update the custom fields and property setters for all child tables
|
||||
for d in frappe.get_meta(doctype).get_table_fields():
|
||||
export_customizations(module, d.options, sync_on_migrate, with_permissions)
|
||||
export_customizations(
|
||||
module, d.options, sync_on_migrate, with_permissions, apply_module_export_filter
|
||||
)
|
||||
|
||||
if custom["custom_fields"] or custom["property_setters"] or custom["custom_perms"]:
|
||||
folder_path = os.path.join(get_module_path(module), "custom")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue