From e5735d0a467afcfc66a2b17275b27d4cf80789bf Mon Sep 17 00:00:00 2001 From: "Chong Wang (cwg)" Date: Wed, 15 Jun 2022 19:16:07 +0200 Subject: [PATCH] [IMP] web: improve Edit Translations button Previously, 'Edit Translations' button is used to translate the English field ir_ui_view.arch A dialog for list view of all translations is opened After this commit, a new 'EN' button is used to translate the Engligsh field ir_ui_view.arch A translation dialog (like other translatable fields) for all translations is opened General idea of the implementation: 1. add the invisible ir_ui_view.arch_db field to the form view before ir_ui_view.arch 2. show the 'Lang' button in the edit mode and make it look like a button for its next field ir_ui_view.arch 3. Forcely change the 'Lang' button to 'EN' --- addons/web/static/src/legacy/scss/form_view.scss | 14 ++++++++++++++ .../web/static/src/views/form/form_controller.scss | 14 ++++++++++++++ odoo/addons/base/models/ir_ui_view.py | 4 ---- odoo/addons/base/views/ir_ui_view_views.xml | 3 +-- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/addons/web/static/src/legacy/scss/form_view.scss b/addons/web/static/src/legacy/scss/form_view.scss index 691d2a8a06b..9fd8d25a8c0 100644 --- a/addons/web/static/src/legacy/scss/form_view.scss +++ b/addons/web/static/src/legacy/scss/form_view.scss @@ -713,6 +713,20 @@ $o-form-label-margin-right: 0px; padding-right: 25px; } } + .oe_no_translation_content { + &:not(.btn) { + display: none; + } + &.btn { + width: 100% !important; + margin-left: 0px; + visibility: hidden; + } + &.btn:after { + content: 'EN'; + visibility: visible; + } + } // Text field with oe_inline class .o_field_text.oe_inline { diff --git a/addons/web/static/src/views/form/form_controller.scss b/addons/web/static/src/views/form/form_controller.scss index c269c4d179b..09af88c8b16 100644 --- a/addons/web/static/src/views/form/form_controller.scss +++ b/addons/web/static/src/views/form/form_controller.scss @@ -436,6 +436,20 @@ $o-form-label-margin-right: 0px; padding-right: 25px; } } + .oe_no_translation_content { + :not(.btn) { + display: none; + } + .btn { + width: 100% !important; + margin-left: 0px; + visibility: hidden; + } + .btn:after { + content: 'EN'; + visibility: visible; + } + } iframe.wysiwyg_iframe + .o_field_translate { right: 30px !important; top: 7px !important; diff --git a/odoo/addons/base/models/ir_ui_view.py b/odoo/addons/base/models/ir_ui_view.py index bc3cc04a423..22ae309fac8 100644 --- a/odoo/addons/base/models/ir_ui_view.py +++ b/odoo/addons/base/models/ir_ui_view.py @@ -2037,10 +2037,6 @@ actual arch. # Misc #------------------------------------------------------ - def open_translations(self): - """ Open a view for editing the translations of field 'arch_db'. """ - return self.env['ir.translation'].translate_fields('ir.ui.view', self.id, 'arch_db') - @api.model def _validate_custom_views(self, model): """Validate architecture of custom views (= without xml id) for a given model. diff --git a/odoo/addons/base/views/ir_ui_view_views.xml b/odoo/addons/base/views/ir_ui_view_views.xml index aa0a2003e7e..c989e819c07 100644 --- a/odoo/addons/base/views/ir_ui_view_views.xml +++ b/odoo/addons/base/views/ir_ui_view_views.xml @@ -28,8 +28,7 @@ -