Merge pull request #16278 from surajshetty3416/is-system-generated-customization

This commit is contained in:
Suraj Shetty 2022-03-23 10:52:21 +05:30 committed by GitHub
commit cd8bd4ccf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 43 additions and 8 deletions

View file

@ -1266,7 +1266,7 @@ def get_newargs(fn, kwargs):
return newargs
def make_property_setter(args, ignore_validate=False, validate_fields_for_doctype=True):
def make_property_setter(args, ignore_validate=False, validate_fields_for_doctype=True, is_system_generated=True):
"""Create a new **Property Setter** (for overriding DocType and DocField properties).
If doctype is not specified, it will create a property setter for all fields with the
@ -1297,6 +1297,7 @@ def make_property_setter(args, ignore_validate=False, validate_fields_for_doctyp
'property': args.property,
'value': args.value,
'property_type': args.property_type or "Data",
'is_system_generated': is_system_generated,
'__islocal': 1
})
ps.flags.ignore_validate = ignore_validate

View file

@ -7,6 +7,7 @@
"document_type": "Setup",
"engine": "InnoDB",
"field_order": [
"is_system_generated",
"dt",
"module",
"label",
@ -425,13 +426,20 @@
"fieldtype": "Link",
"label": "Module (for export)",
"options": "Module Def"
},
{
"default": "0",
"fieldname": "is_system_generated",
"fieldtype": "Check",
"label": "Is System Generated",
"read_only": 1
}
],
"icon": "fa fa-glass",
"idx": 1,
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-02-14 15:42:21.885999",
"modified": "2022-02-28 22:22:54.893269",
"modified_by": "Administrator",
"module": "Custom",
"name": "Custom Field",

View file

@ -119,7 +119,7 @@ def create_custom_field_if_values_exist(doctype, df):
frappe.db.count(dt=doctype, filters=IfNull(df.fieldname, "") != ""):
create_custom_field(doctype, df)
def create_custom_field(doctype, df, ignore_validate=False):
def create_custom_field(doctype, df, ignore_validate=False, is_system_generated=True):
df = frappe._dict(df)
if not df.fieldname and df.label:
df.fieldname = frappe.scrub(df.label)
@ -130,8 +130,7 @@ def create_custom_field(doctype, df, ignore_validate=False):
"permlevel": 0,
"fieldtype": 'Data',
"hidden": 0,
# Looks like we always use this programatically?
# "is_standard": 1
"is_system_generated": is_system_generated
})
custom_field.update(df)
custom_field.flags.ignore_validate = ignore_validate

View file

@ -242,7 +242,8 @@ frappe.ui.form.on("Customize Form Field", {
},
fields_add: function(frm, cdt, cdn) {
var f = frappe.model.get_doc(cdt, cdn);
f.is_custom_field = 1;
f.is_system_generated = false;
f.is_custom_field = true;
}
});

View file

@ -402,7 +402,7 @@ class CustomizeForm(Document):
"property": prop,
"value": value,
"property_type": property_type
})
}, is_system_generated=False)
def get_existing_property_value(self, property_name, fieldname=None):
# check if there is any need to make property setter!

View file

@ -6,6 +6,7 @@
"document_type": "Setup",
"engine": "InnoDB",
"field_order": [
"is_system_generated",
"help",
"sb0",
"doctype_or_field",
@ -103,13 +104,20 @@
{
"fieldname": "section_break_9",
"fieldtype": "Section Break"
},
{
"default": "0",
"fieldname": "is_system_generated",
"fieldtype": "Check",
"label": "Is System Generated",
"read_only": 1
}
],
"icon": "fa fa-glass",
"idx": 1,
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-12-14 14:15:41.929071",
"modified": "2022-02-28 22:24:12.377693",
"modified_by": "Administrator",
"module": "Custom",
"name": "Property Setter",

View file

@ -197,4 +197,5 @@ frappe.patches.v14_0.copy_mail_data #08.03.21
frappe.patches.v14_0.update_github_endpoints #08-11-2021
frappe.patches.v14_0.remove_db_aggregation
frappe.patches.v14_0.update_color_names_in_kanban_board_column
frappe.patches.v14_0.update_is_system_generated_flag
frappe.patches.v14_0.update_auto_account_deletion_duration

View file

@ -0,0 +1,17 @@
import frappe
def execute():
# assuming all customization generated by Admin is system generated customization
custom_field = frappe.qb.DocType("Custom Field")
(
frappe.qb.update(custom_field)
.set(custom_field.is_system_generated, True)
.where(custom_field.owner == 'Administrator').run()
)
property_setter = frappe.qb.DocType("Property Setter")
(
frappe.qb.update(property_setter)
.set(property_setter.is_system_generated, True)
.where(property_setter.owner == 'Administrator').run()
)