Abai
November 15, 2024, 9:06am
1
In the Material Request Doctype, there is a field named Purpose , which is a select field. When I try to add an option named “Demo” to this field and save it, I receive the following error:
“You can’t set ‘Options’ for field Purpose.”
ejaaz
November 15, 2024, 9:18am
2
Yes, because it is not allowed to change options, you can use a property setter to set options.
and cint(df.get("read_only")) == 0
and frappe.db.get_value(
"DocField", {"parent": self.doc_type, "fieldname": df.fieldname}, "read_only"
)
== 1
):
# if docfield has read_only checked and user is trying to make it editable, don't allow it
frappe.msgprint(_("You cannot unset 'Read Only' for field {0}").format(df.label))
return False
elif prop == "options" and df.get("fieldtype") not in ALLOWED_OPTIONS_CHANGE:
frappe.msgprint(_("You can't set 'Options' for field {0}").format(df.label))
return False
elif prop == "translatable" and not supports_translation(df.get("fieldtype")):
frappe.msgprint(_("You can't set 'Translatable' for field {0}").format(df.label))
return False
elif prop == "in_global_search" and df.in_global_search != meta_df[0].get("in_global_search"):
self.flags.rebuild_doctype_for_global_search = True
("Small Text", "Data"),
("Text", "Data"),
("Text", "Text Editor", "Code", "Signature", "HTML Editor"),
("Data", "Select"),
("Text", "Small Text", "Long Text"),
("Text", "Data", "Barcode"),
("Code", "Geolocation"),
("Table", "Table MultiSelect"),
)
ALLOWED_OPTIONS_CHANGE = ("Read Only", "HTML", "Data")