seitime-frappe/frappe/database
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
..
mariadb fix: set translated text to link field (#15451) 2022-05-16 13:21:42 +00:00
postgres fix: set translated text to link field (#15451) 2022-05-16 13:21:42 +00:00
__init__.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
database.py Merge branch 'develop' into aks-feat-dbquery_update 2022-05-09 12:02:36 +05:30
db_manager.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
query.py feat: left join tables by default 2022-04-28 17:10:31 +05:30
schema.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
sequence.py fix: create sequence onchange from any other autoname whcih is not autoincrement 2022-05-05 21:31:13 +05:30