summaryrefslogtreecommitdiff
path: root/odoo
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2019-09-09 14:48:22 +0000
committerMartin Trigaux <mat@odoo.com>2019-09-09 14:57:15 +0000
commit19e50ea37435c2d943fd788c5be38c7a78533dc5 (patch)
tree92521f7c34ee7a47c8ce7380048dcdb3ac8df5e9 /odoo
parent5d2021e79f9e7988a1ab3ddc8d244670d0926d0e (diff)
[FIX] tools: do not translate selections with _translate=False
If a model is tagged with _translate=False, it should not be translated. A special case was made for ir.model.fields but not ir.model.fields.selection Before this commit, the selections of web_editor.converter.test were translated closes odoo/odoo#36576 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Diffstat (limited to 'odoo')
-rw-r--r--odoo/tools/translate.py34
1 files changed, 18 insertions, 16 deletions
diff --git a/odoo/tools/translate.py b/odoo/tools/translate.py
index 4ad33bb0341..39edaee9423 100644
--- a/odoo/tools/translate.py
+++ b/odoo/tools/translate.py
@@ -890,6 +890,21 @@ def trans_generate(lang, modules, cr):
tnx = (module, source, name, id, type, tuple(comments or ()))
to_translate.add(tnx)
+ def translatable_model(record):
+ if not record._translate:
+ return False
+
+ if record._name == 'ir.model.fields.selection':
+ record = record.field_id
+ if record._name == 'ir.model.fields':
+ field_name = record.name
+ field_model = env.get(record.model)
+ if (field_model is None or not field_model._translate or
+ field_name not in field_model._fields):
+ return False
+
+ return True
+
query = 'SELECT min(name), model, res_id, module FROM ir_model_data'
if 'all_installed' in modules:
@@ -914,25 +929,12 @@ def trans_generate(lang, modules, cr):
continue
record = env[model].browse(res_id)
- if not record._translate:
- # explicitly disabled
- continue
-
if not record.exists():
_logger.warning(u"Unable to find object %r with id %d", model, res_id)
- continue
+ return False
- if model==u'ir.model.fields':
- try:
- field_name = record.name
- except AttributeError as exc:
- _logger.error(u"name error in %s: %s", xml_name, str(exc))
- continue
- field_model = env.get(record.model)
- if (field_model is None or not field_model._translate or
- field_name not in field_model._fields):
- continue
- field = field_model._fields[field_name]
+ if not translatable_model(record):
+ continue
for field_name, field in record._fields.items():
if field.translate: