seitime-frappe/frappe/core
Himanshu 70409a3c7b
fix: set translated text to link field (#15451)
- Fixes [Issue/15324](https://github.com/frappe/frappe/issues/15324)
- When selecting a value for Link Field, the English text was set as link field value.
- This PR aims to fix it by setting the translated text as link field value on selection.

Todo:

- [x] Show translated text in the select dropdown
- [x] Set translated value to Link field on select
- [x] Show original value when link field is in focus
- [x] Add option to toggle this behaviour

### Behaviour

- Link field loses focus: show the translated name.
- Link field is focused
    - If old value is present
        - If options **are** one of [Role, DocType]: show the translated name
        - Else: show the name (untranslated) to enable search in untranslated values
    - Else: show what the user typed (untranslated) to enable search in untranslated values
- Value is selected: link field loses focus

## Demo

### Link to UOM in a custom Item DocType

The UOM names are in english, so the search needs to happen in english. When possible, the translation is displayed.

#### Before

https://user-images.githubusercontent.com/14891507/156415248-e5e80d05-53dc-4ca8-89c7-998986ff6e99.mov

#### After

https://user-images.githubusercontent.com/14891507/156410386-a874430c-f340-43ed-9c3a-92e8d4d50fc9.mov

### Link to DocType in Customize Form

The DocType names get translated before being searched. This is a preexisting hack in the framework for DocType and Role. In this case, we can search in the translations.

#### Before

https://user-images.githubusercontent.com/14891507/156414648-8e505f8c-9dee-4358-8182-3b358c28bb62.mov

#### After

https://user-images.githubusercontent.com/14891507/156411881-c4ca22e1-1397-4e13-9768-5e16b72f8d6d.mov

https://docs.erpnext.com/docs/v13/user/manual/en/customize-erpnext/customize-form/edit?wiki_page_patch=fdafee2715
2022-05-16 13:21:42 +00:00
..
doctype fix: set translated text to link field (#15451) 2022-05-16 13:21:42 +00:00
form_tour/doctype fix: module load issue, tour description and save field overlay 2021-11-25 17:57:07 +05:30
page fix: current job was not shown in workers view 2022-04-16 08:04:07 +05:30
report style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
web_form style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
workspace fix: updated standard workspace json files 2022-01-13 18:40:36 +05:30
__init__.py chore: Update header: license.txt => LICENSE 2021-09-03 12:02:59 +05:30
notifications.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
README.md rename Profile to User frappe/frappe#470 2014-03-11 16:14:47 +05:30
utils.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30

Core module contains the models required for the basic functioning of frappe including DocType, User (user), Role and others.