Add model fields on translation
Use for client plugin to be able to find record to translate
This commit is contained in:
1 parent
f11e17a0ff
commit
2dfd118573
2 files changed
+21
-2
No files matched your search
@@ -37,6 +37,23 @@ class Translation(OSV, Cacheable):
|
||||
res = [(lang.code, lang.name) for lang in langs]
|
||||
return res
|
||||
|
||||
def _model(self, cursor, user, ids, name, arg, context=None):
|
||||
res = {}
|
||||
for translation in self.browse(cursor, user, ids, context=context):
|
||||
res[translation.id] = translation.name.split(',')[0]
|
||||
return res
|
||||
|
||||
def _model_search(self, cursor, user, obj, name, args, context=None):
|
||||
args2 = []
|
||||
i = 0
|
||||
while i < len(args):
|
||||
cursor.execute('SELECT id FROM ir_translation ' \
|
||||
'WHERE split_part(name, \',\', 1) ' + args[i][1] + ' %s',
|
||||
(args[i][2],))
|
||||
args2.append(('id', 'in', [x[0] for x in cursor.fetchall()]))
|
||||
i += 1
|
||||
return args2
|
||||
|
||||
_columns = {
|
||||
'name': fields.Char('Field Name', size=128, required=True),
|
||||
'res_id': fields.Integer('Resource ID'),
|
||||
@@ -47,6 +64,8 @@ class Translation(OSV, Cacheable):
|
||||
'value': fields.Text('Translation Value'),
|
||||
'module': fields.Char('Module', size=128, readonly=True),
|
||||
'fuzzy': fields.Boolean('Fuzzy'),
|
||||
'model': fields.Function(_model, fnct_search=_model_search,
|
||||
method=True, type='char', string='Model'),
|
||||
}
|
||||
_defaults = {
|
||||
'fuzzy': lambda *a: 0,
|
||||
|
||||
@@ -497,10 +497,10 @@ class Function(_column):
|
||||
self._symbol_f = lambda x: __builtin__.float(x or 0.0)
|
||||
self._symbol_set = (self._symbol_c, self._symbol_f)
|
||||
|
||||
def search(self, cursor, user, obj, name, arg, context=None):
|
||||
def search(self, cursor, user, obj, name, args, context=None):
|
||||
if not self._fnct_search:
|
||||
return []
|
||||
return self._fnct_search(obj, cursor, user, obj, name, arg,
|
||||
return self._fnct_search(obj, cursor, user, obj, name, args,
|
||||
context=context)
|
||||
|
||||
def get(self, cursor, obj, ids, name, user=None, offset=0, context=None,
|
||||
|
||||
Reference in new issue
Block a user