[IMP] BaseModel: new `_translate` attribute to disable translations

Can be defined to False in any model to completely
disable translations for this model, when they are
irrelevant. This is useful e.g. for test classes
that use attributes that would normally be translatable.
This commit is contained in:
Olivier Dony 2014-07-14 16:36:48 +02:00
parent 9a9ef37c65
commit 77769ce74d
2 changed files with 7 additions and 1 deletions

View File

@ -295,6 +295,7 @@ class BaseModel(object):
_sequence = None
_description = None
_needaction = False
_translate = True # set to False to disable translations export for this model
# dict of {field:method}, with method returning the (name_get of records, {id: fold})
# to include in the _read_group, if grouped on this field

View File

@ -668,6 +668,10 @@ def trans_generate(lang, modules, cr):
_logger.error("Unable to find object %r", model)
continue
if not registry[model]._translate:
# explicitly disabled
continue
exists = registry[model].exists(cr, uid, res_id)
if not exists:
_logger.warning("Unable to find object %r with id %d", model, res_id)
@ -688,7 +692,8 @@ def trans_generate(lang, modules, cr):
_logger.error("name error in %s: %s", xml_name, str(exc))
continue
objmodel = registry.get(obj.model)
if objmodel is None or field_name not in objmodel._columns:
if (objmodel is None or field_name not in objmodel._columns
or not objmodel._translate):
continue
field_def = objmodel._columns[field_name]