fix(patch): Remove obviously invalid fetch from expressions (#25284)
This commit is contained in:
parent
8cf0c53eb7
commit
4f4a387b7e
3 changed files with 27 additions and 0 deletions
|
|
@ -0,0 +1,26 @@
|
|||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
"""Remove invalid fetch from expressions"""
|
||||
|
||||
property_setters = frappe.get_all(
|
||||
"Property Setter", {"doctype_or_field": "DocField", "property": "fetch_from"}, ["name", "value"]
|
||||
)
|
||||
for ps in property_setters:
|
||||
if not is_valid_expression(ps.value):
|
||||
frappe.db.delete("Property Setter", {"name": ps.name})
|
||||
|
||||
custom_fields = frappe.get_all("Custom Field", {"fetch_from": ("is", "set")}, ["name", "fetch_from"])
|
||||
for cf in custom_fields:
|
||||
if not is_valid_expression(cf.fetch_from):
|
||||
frappe.db.set_value("Custom Field", cf.name, "fetch_from", "")
|
||||
|
||||
|
||||
def is_valid_expression(expr) -> bool:
|
||||
if not expr or "." not in expr:
|
||||
return False
|
||||
source_field, target_field = expr.split(".")
|
||||
if not source_field or not target_field:
|
||||
return False
|
||||
return True
|
||||
|
|
@ -235,3 +235,4 @@ frappe.patches.v15_0.validate_newsletter_recipients
|
|||
frappe.patches.v15_0.sanitize_workspace_titles
|
||||
frappe.patches.v15_0.migrate_role_profile_to_table_multi_select
|
||||
frappe.patches.v15_0.migrate_session_data
|
||||
frappe.custom.doctype.property_setter.patches.remove_invalid_fetch_from_expressions
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue