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
This commit is contained in:
parent
8220e0ad02
commit
ee881fa7e0
|
@ -81,7 +81,8 @@ class wizard_export_lang(osv.osv_memory):
|
||||||
('get','get'), # get the file
|
('get','get'), # get the file
|
||||||
) ),
|
) ),
|
||||||
}
|
}
|
||||||
_defaults = { 'state': lambda *a: 'choose',
|
_defaults = { 'state': lambda *a: 'choose',
|
||||||
|
'name': lambda *a: 'lang.tar.gz'
|
||||||
}
|
}
|
||||||
wizard_export_lang()
|
wizard_export_lang()
|
||||||
|
|
||||||
|
|
|
@ -196,6 +196,9 @@ class browse_record(object):
|
||||||
elif f._type in ('one2many', 'many2many') and len(data[n]):
|
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)
|
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)
|
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]
|
return self._data[self._id][name]
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
|
|
|
@ -359,7 +359,11 @@ def trans_generate(lang, modules, dbname=None):
|
||||||
push_translation(module, 'view', obj.model, 0, t)
|
push_translation(module, 'view', obj.model, 0, t)
|
||||||
elif model=='ir.actions.wizard':
|
elif model=='ir.actions.wizard':
|
||||||
service_name = 'wizard.'+obj.wiz_name
|
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():
|
for state_name, state_def in obj2.states.iteritems():
|
||||||
if 'result' in state_def:
|
if 'result' in state_def:
|
||||||
result = state_def['result']
|
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)
|
push_translation(module, 'wizard_button', res_name, 0, button_label)
|
||||||
|
|
||||||
elif model=='ir.model.fields':
|
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)
|
objmodel = pool.get(obj.model)
|
||||||
if not objmodel or not field_name in objmodel._columns:
|
if not objmodel or not field_name in objmodel._columns:
|
||||||
continue
|
continue
|
||||||
|
@ -446,7 +454,10 @@ def trans_generate(lang, modules, dbname=None):
|
||||||
for field_name,field_def in pool.get(model)._columns.items():
|
for field_name,field_def in pool.get(model)._columns.items():
|
||||||
if field_def.translate:
|
if field_def.translate:
|
||||||
name = model + "," + field_name
|
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)
|
push_translation(module, 'model', name, xml_name, trad)
|
||||||
|
|
||||||
# parse source code for _() calls
|
# parse source code for _() calls
|
||||||
|
|
Loading…
Reference in New Issue