[IMP] base: display field translation in a popup
The goal of this change is to allow the user to stay in the form view and edit the translations in one go. Generate also English translations to make the source=English a bit less true. It was already the case for callable translations method Adapt the test that was ambigious (verified no French translation was duplicated but an English translation is created)
This commit is contained in:
@@ -620,7 +620,7 @@ class IrTranslation(models.Model):
|
||||
query = """ INSERT INTO ir_translation (lang, type, name, res_id, src, module, state)
|
||||
SELECT l.code, 'model', %(name)s, %(res_id)s, %(src)s, %(module)s, 'to_translate'
|
||||
FROM res_lang l
|
||||
WHERE l.active AND l.translatable AND l.code != 'en_US' AND NOT EXISTS (
|
||||
WHERE l.active AND l.translatable AND NOT EXISTS (
|
||||
SELECT 1 FROM ir_translation
|
||||
WHERE lang=l.code AND type='model' AND name=%(name)s AND res_id=%(res_id)s
|
||||
);
|
||||
@@ -746,6 +746,12 @@ class IrTranslation(models.Model):
|
||||
except AccessError:
|
||||
pass
|
||||
|
||||
action['target'] = 'new'
|
||||
if callable(fld.translate):
|
||||
action['view_id'] = self.env.ref('base.view_translation_lang_src_value_tree').id,
|
||||
else:
|
||||
action['view_id'] = self.env.ref('base.view_translation_lang_value_tree').id,
|
||||
|
||||
return action
|
||||
|
||||
@api.model
|
||||
|
||||
@@ -327,7 +327,7 @@ class TestTranslation(TransactionCase):
|
||||
})
|
||||
self.env['ir.translation'].translate_fields('res.partner.category', padawans.id, 'name')
|
||||
translations = self.env['ir.translation'].search([
|
||||
('res_id', '=', padawans.id), ('name', '=', 'res.partner.category,name')
|
||||
('res_id', '=', padawans.id), ('name', '=', 'res.partner.category,name'), ('lang', '=', 'fr_FR'),
|
||||
])
|
||||
self.assertEqual(len(translations), 1, "Translations were not duplicated after `translate_fields` call")
|
||||
self.assertEqual(translations.value, "Apprenti", "The first translation must stay")
|
||||
|
||||
@@ -78,6 +78,27 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_translation_lang_value_tree" model="ir.ui.view">
|
||||
<field name="model">ir.translation</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Translations" editable="top" create="false">
|
||||
<field name="lang" readonly="1"/>
|
||||
<field name="value"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_translation_lang_src_value_tree" model="ir.ui.view">
|
||||
<field name="model">ir.translation</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Translations" editable="top" create="false">
|
||||
<field name="lang" readonly="1"/>
|
||||
<field name="src" readonly="1"/>
|
||||
<field name="value"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_translation" model="ir.actions.act_window">
|
||||
<field name="name">Translated Terms</field>
|
||||
<field name="res_model">ir.translation</field>
|
||||
|
||||
Reference in New Issue
Block a user