summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorP. Christeas <p_christ@hol.gr>2008-11-15 10:58:54 +0200
committerP. Christeas <p_christ@hol.gr>2008-11-15 10:58:54 +0200
commitee881fa7e05fc0bb7b7de37579f8f23a50dc8f9e (patch)
tree13dec7b04a249cd8c4bffff9b40f32b831834b1b
parent8220e0ad02c27bbcdae91a0a04aa7e0d1cf72cef (diff)
Armor the export lang wizard against faulty model fields.
Sometimes objects or field definitions in db may have some errors (especially in dev setups). The export translation algorithm should just skip those fields and try to continue, instead of raising an exception. These errors can still be logged, of course. bzr revid: p_christ@hol.gr-20081115085854-2xpnypbas4sxt15u
-rw-r--r--bin/addons/base/module/wizard/wizard_export_lang.py3
-rw-r--r--bin/osv/orm.py3
-rw-r--r--bin/tools/translate.py17
3 files changed, 19 insertions, 4 deletions
diff --git a/bin/addons/base/module/wizard/wizard_export_lang.py b/bin/addons/base/module/wizard/wizard_export_lang.py
index 2e9751e55e5..c6ce9f75e19 100644
--- a/bin/addons/base/module/wizard/wizard_export_lang.py
+++ b/bin/addons/base/module/wizard/wizard_export_lang.py
@@ -81,7 +81,8 @@ class wizard_export_lang(osv.osv_memory):
('get','get'), # get the file
) ),
}
- _defaults = { 'state': lambda *a: 'choose',
+ _defaults = { 'state': lambda *a: 'choose',
+ 'name': lambda *a: 'lang.tar.gz'
}
wizard_export_lang()
diff --git a/bin/osv/orm.py b/bin/osv/orm.py
index b40e486e174..0571bbbd99e 100644
--- a/bin/osv/orm.py
+++ b/bin/osv/orm.py
@@ -196,6 +196,9 @@ class browse_record(object):
elif f._type in ('one2many', 'many2many') and len(data[n]):
data[n] = self._list_class([browse_record(self._cr, self._uid, id, self._table.pool.get(f._obj), self._cache, context=self._context, list_class=self._list_class, fields_process=self._fields_process) for id in data[n]], self._context)
self._data[data['id']].update(data)
+ if not name in self._data[self._id]:
+ #how did this happen?
+ raise AttributeError(_('Unknown attribute % in % ') % (name,self._id))
return self._data[self._id][name]
def __getattr__(self, name):
diff --git a/bin/tools/translate.py b/bin/tools/translate.py
index 7e382ce99bb..bb59aca11e8 100644
--- a/bin/tools/translate.py
+++ b/bin/tools/translate.py
@@ -359,7 +359,11 @@ def trans_generate(lang, modules, dbname=None):
push_translation(module, 'view', obj.model, 0, t)
elif model=='ir.actions.wizard':
service_name = 'wizard.'+obj.wiz_name
- obj2 = netsvc._service[service_name]
+ try:
+ obj2 = netsvc._service[service_name]
+ except KeyError, exc:
+ logger.notifyChannel("db", netsvc.LOG_ERROR, "key error in %s: %s" % (xml_name,str(exc)))
+ continue
for state_name, state_def in obj2.states.iteritems():
if 'result' in state_def:
result = state_def['result']
@@ -389,7 +393,11 @@ def trans_generate(lang, modules, dbname=None):
push_translation(module, 'wizard_button', res_name, 0, button_label)
elif model=='ir.model.fields':
- field_name = obj.name
+ try:
+ field_name = obj.name
+ except AttributeError, exc:
+ logger.notifyChannel("db", netsvc.LOG_ERROR, "name error in %s: %s" % (xml_name,str(exc)))
+ continue
objmodel = pool.get(obj.model)
if not objmodel or not field_name in objmodel._columns:
continue
@@ -446,7 +454,10 @@ def trans_generate(lang, modules, dbname=None):
for field_name,field_def in pool.get(model)._columns.items():
if field_def.translate:
name = model + "," + field_name
- trad = getattr(obj, field_name) or ''
+ try:
+ trad = getattr(obj, field_name) or ''
+ except:
+ trad = ''
push_translation(module, 'model', name, xml_name, trad)
# parse source code for _() calls