Add translate argument to Selection to prevent translation of selection list
This commit is contained in:
@@ -747,7 +747,8 @@ class TranslationClean(Wizard):
|
||||
to_delete.append(translation.id)
|
||||
continue
|
||||
field = model_obj._columns[field_name]
|
||||
if not hasattr(field, 'selection') or not field.selection:
|
||||
if not hasattr(field, 'selection') or not field.selection \
|
||||
or not field.translate:
|
||||
to_delete.append(translation.id)
|
||||
continue
|
||||
if isinstance(field.selection, (tuple, list)) \
|
||||
|
||||
@@ -262,14 +262,15 @@ class Binary(Column):
|
||||
class Selection(Column):
|
||||
_type = 'selection'
|
||||
|
||||
def __init__(self, selections, string='unknown', sort=True, **args):
|
||||
def __init__(self, selections, string='unknown', sort=True, translate=True,
|
||||
**args):
|
||||
"""
|
||||
selections is a list of (key, string)
|
||||
or the name of the object function that return the list
|
||||
"""
|
||||
self.sort = sort
|
||||
Column.__init__(self, string=string, selection=selections,
|
||||
**args)
|
||||
translate=translate, **args)
|
||||
|
||||
def sql_type(self):
|
||||
if self.size:
|
||||
|
||||
+6
-3
@@ -431,7 +431,8 @@ class ORM(object):
|
||||
'WHERE id = %s ',
|
||||
(field.help, trans_help[trans_name]['id']))
|
||||
if hasattr(field, 'selection') \
|
||||
and isinstance(field.selection, (tuple, list)):
|
||||
and isinstance(field.selection, (tuple, list)) \
|
||||
and field.translate:
|
||||
for (key, val) in field.selection:
|
||||
if trans_name not in trans_selection \
|
||||
or val not in trans_selection[trans_name]:
|
||||
@@ -1901,7 +1902,8 @@ class ORM(object):
|
||||
trans_args.append((self._name + ',' + field, 'help',
|
||||
context['language'], None))
|
||||
if hasattr(self._columns[field], 'selection'):
|
||||
if isinstance(self._columns[field].selection, (tuple, list)):
|
||||
if isinstance(self._columns[field].selection, (tuple, list)) \
|
||||
and self._columns[field].translate:
|
||||
sel = self._columns[field].selection
|
||||
for (key, val) in sel:
|
||||
trans_args.append((self._name + ',' + field,
|
||||
@@ -1957,7 +1959,8 @@ class ORM(object):
|
||||
if hasattr(self._columns[field], 'selection'):
|
||||
if isinstance(self._columns[field].selection, (tuple, list)):
|
||||
sel = self._columns[field].selection
|
||||
if context.get('language'):
|
||||
if context.get('language') and \
|
||||
self._columns[field].translate:
|
||||
# translate each selection option
|
||||
sel2 = []
|
||||
for (key, val) in sel:
|
||||
|
||||
Reference in New Issue
Block a user