fix: Translate names if "Translate Link Fields" is enabled

This commit is contained in:
marination 2025-03-11 19:57:53 +01:00
parent 42f977ef59
commit 943adecae3

View file

@ -752,8 +752,14 @@ def get_link_options(web_form_name, doctype, allow_read_on_all_link_options=Fals
if meta.translated_doctype:
# Translate the labels if "Translate Link Fields" is enabled
link_options = [{"value": row.value, "label": _(row.label)} for row in link_options]
return json.dumps(link_options, default=str)
else:
if meta.translated_doctype:
# Add `label` as the translated name if "Translate Link Fields" is enabled
return [{"value": row.value, "label": _(row.value)} for row in link_options]
# Use the actual names as options without labels
return "\n".join([str(doc.value) for doc in link_options])