[IMP] BaseModel: new `_translate` attribute to disable translations
authorOlivier Dony <odo@openerp.com>
Mon, 14 Jul 2014 14:36:48 +0000 (16:36 +0200)
committerOlivier Dony <odo@openerp.com>
Wed, 30 Jul 2014 11:24:39 +0000 (13:24 +0200)
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.

openerp/models.py
openerp/tools/translate.py

index 1b75bd2..c4c7f69 100644 (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
index 01d945c..25ee421 100644 (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]