[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'
This commit is contained in:
Chong Wang (cwg)
2022-09-15 22:37:50 +02:00
parent b43d117e0e
commit e5735d0a46
4 changed files with 29 additions and 6 deletions
@@ -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 {
@@ -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;
-4
View File
@@ -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.
+1 -2
View File
@@ -28,8 +28,7 @@
</div>
<notebook>
<page string="Architecture" name="architecture">
<button type="object" name="open_translations"
string="Edit Translations" class="oe_link oe_right"/>
<field name="arch_db" class="oe_no_translation_content"/>
<field name="arch_base" string="View Architecture" widget="ace" options="{'mode': 'xml'}" required="1"/>
</page>
<page string="Access Rights" name="access_rights">