report-openoffice-team team mailing list archive
-
report-openoffice-team team
-
Mailing list archive
-
Message #00182
[Bug 646271] [NEW] Translation in slection items
Public bug reported:
Try to use get_selection_item with french translation.
No way to have field in french.
Modify extrafunction with adaption of code from orm :
def _get_selection_item(self, obj, field):
try:
if isinstance(obj, report_sxw.browse_record_list):
obj = obj[0]
if type(obj)==str:
model = obj
else:
model = obj._table_name
field_val = getattr(obj, field)
if field_val:
selection = self.pool.get(model)._columns[field].selection
if selection.__class__==list:
translation_obj = self.pool.get('ir.translation')
sel2 = []
for (key, val) in selection:
val2 = None
if val:
val2 = translation_obj._get_source(self.cr, self.uid, self.pool.get(model)._name + ',' + field, 'selection', self._get_lang(), val)
sel2.append((key, val2 or val))
val_dict = dict(sel2)
else:
val_dict = dict(selection(self.pool.get(model), self.cr, self.uid, {'lang':self._get_lang()}))
return val_dict[field_val]
return ''
except Exception:
return ''
selection items appear in french.
** Affects: report-openoffice
Importance: Undecided
Status: New
--
Translation in slection items
https://bugs.launchpad.net/bugs/646271
You received this bug notification because you are a member of Report
OpenOffice Team, which is the registrant for Report OpenOffice.
Status in OpenOffice.org Reporting Engine for OpenObject: New
Bug description:
Try to use get_selection_item with french translation.
No way to have field in french.
Modify extrafunction with adaption of code from orm :
def _get_selection_item(self, obj, field):
try:
if isinstance(obj, report_sxw.browse_record_list):
obj = obj[0]
if type(obj)==str:
model = obj
else:
model = obj._table_name
field_val = getattr(obj, field)
if field_val:
selection = self.pool.get(model)._columns[field].selection
if selection.__class__==list:
translation_obj = self.pool.get('ir.translation')
sel2 = []
for (key, val) in selection:
val2 = None
if val:
val2 = translation_obj._get_source(self.cr, self.uid, self.pool.get(model)._name + ',' + field, 'selection', self._get_lang(), val)
sel2.append((key, val2 or val))
val_dict = dict(sel2)
else:
val_dict = dict(selection(self.pool.get(model), self.cr, self.uid, {'lang':self._get_lang()}))
return val_dict[field_val]
return ''
except Exception:
return ''
selection items appear in french.
Follow ups
References