I customized one Opportunity doctype with one custom field with the name custom_test I wrote a code for that, and it’s working fine but it’s not reflecting on the opportunity custum_field in customize form what is the issue help regarding this topic
import frappe
def update_custom_select_field():
sales_stages = frappe.get_all("Sales Stage", filters={}, fields=["stage_name"])
stage_names = [stage.get("stage_name") for stage in sales_stages]
opportunity_meta = frappe.get_meta("Opportunity")
custom_select_field = None
for field in opportunity_meta.fields:
if field.fieldname == "custom_test":
custom_select_field = field
break
if custom_select_field:
# Set the options for the custom select field as a list of strings
custom_select_field.options = "\n".join(stage_names)
# Print some debugging information
print("Before saving meta:")
print(custom_select_field.options)
# Save the modified meta
opportunity_meta.save()
frappe.db.commit()
print("After saving meta:")
print(custom_select_field.options)
else:
print("custom_test field not found in Opportunity doctype.")
# Call the function to update the custom select field options
update_custom_select_field()