[IMP] base: do not set a value for new translations
When generating new translations (e.g. 'edit translations' button on a view or on a translatable field), the new generated translations have the source as translation value. Set the state to 'to_translate' as it is the default value This change requires to add a fallback in web_editor when computing translated dom When a translation has no value, there is a fallback done in the different translation method (e.g. xml_translate) but, as the node was manually created in edit_translation_mapping, the fallback was missing closes odoo/odoo#24391
This commit is contained in:
@@ -8,7 +8,7 @@ from odoo.tools.translate import encode, xml_translate, html_translate
|
||||
|
||||
|
||||
def edit_translation_mapping(data):
|
||||
data = dict(data, model=data['name'].partition(',')[0])
|
||||
data = dict(data, model=data['name'].partition(',')[0], value=data['value'] or data['src'])
|
||||
return '<span data-oe-model="%(model)s" data-oe-translation-id="%(id)s" data-oe-translation-state="%(state)s">%(value)s</span>' % data
|
||||
|
||||
|
||||
|
||||
@@ -590,8 +590,8 @@ class IrTranslation(models.Model):
|
||||
external_ids = records.get_external_id() # if no xml_id, empty string
|
||||
if callable(field.translate):
|
||||
# insert missing translations for each term in src
|
||||
query = """ INSERT INTO ir_translation (lang, type, name, res_id, src, value, module)
|
||||
SELECT l.code, 'model', %(name)s, %(res_id)s, %(src)s, %(src)s, %(module)s
|
||||
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 NOT EXISTS (
|
||||
SELECT 1 FROM ir_translation
|
||||
@@ -610,8 +610,8 @@ class IrTranslation(models.Model):
|
||||
})
|
||||
else:
|
||||
# insert missing translations for src
|
||||
query = """ INSERT INTO ir_translation (lang, type, name, res_id, src, value, module)
|
||||
SELECT l.code, 'model', %(name)s, %(res_id)s, %(src)s, %(src)s, %(module)s
|
||||
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 (
|
||||
SELECT 1 FROM ir_translation
|
||||
|
||||
Reference in New Issue
Block a user