Active Record
This commit is contained in:
1 parent
36a18758c4
commit
3e47c94097
5 files changed
+18
-19
No files matched your search
@@ -58,7 +58,7 @@ class Action(object):
|
||||
if not action_type:
|
||||
res = False
|
||||
try:
|
||||
res = RPCExecute('model', 'ir.action', 'read', act_id,
|
||||
res, = RPCExecute('model', 'ir.action', 'read', [act_id],
|
||||
['type'], context=context)
|
||||
except RPCException:
|
||||
return
|
||||
@@ -66,7 +66,7 @@ class Action(object):
|
||||
raise Exception('ActionNotFound')
|
||||
action_type = res['type']
|
||||
try:
|
||||
res = RPCExecute('model', action_type, 'search_read',
|
||||
res, = RPCExecute('model', action_type, 'search_read',
|
||||
[('action', '=', act_id)], 0, 1, None, None,
|
||||
context=context)
|
||||
except RPCException:
|
||||
|
||||
@@ -42,8 +42,8 @@ class Board(SignalEvent, TabContent):
|
||||
super(Board, self).__init__()
|
||||
|
||||
try:
|
||||
view = RPCExecute('model', 'ir.ui.view', 'read',
|
||||
view_id, ['arch'], context=context)
|
||||
view, = RPCExecute('model', 'ir.ui.view', 'read',
|
||||
[view_id], ['arch'], context=context)
|
||||
except RPCException:
|
||||
raise
|
||||
|
||||
|
||||
@@ -420,8 +420,8 @@ class M2OField(CharField):
|
||||
value = None
|
||||
if not rec_name and value >= 0:
|
||||
try:
|
||||
result = RPCExecute('model', self.attrs['relation'], 'read',
|
||||
value, ['rec_name'])
|
||||
result, = RPCExecute('model', self.attrs['relation'], 'read',
|
||||
[value], ['rec_name'])
|
||||
except RPCException:
|
||||
return False
|
||||
rec_name = result['rec_name'] or ''
|
||||
@@ -543,7 +543,7 @@ class O2MField(CharField):
|
||||
get_readonly=readonly, get_modifiedonly=modified)
|
||||
values.pop(parent_name, None)
|
||||
if record2.modified and values:
|
||||
result.append(('write', record2.id, values))
|
||||
result.append(('write', [record2.id], values))
|
||||
result[0][1].append(record2.id)
|
||||
else:
|
||||
values = record2.get(check_load=check_load,
|
||||
@@ -854,7 +854,7 @@ class ReferenceField(CharField):
|
||||
if ref_model and ref_id >= 0:
|
||||
if not rec_name and ref_id >= 0:
|
||||
try:
|
||||
result = RPCExecute('model', ref_model, 'read', ref_id,
|
||||
result, = RPCExecute('model', ref_model, 'read', [ref_id],
|
||||
['rec_name'])
|
||||
except RPCException:
|
||||
return
|
||||
|
||||
@@ -285,9 +285,8 @@ class Record(SignalEvent):
|
||||
context = context.copy()
|
||||
context['_timestamp'] = self.get_timestamp()
|
||||
try:
|
||||
if not RPCExecute('model', self.model_name, 'write',
|
||||
[self.id], value, context=context):
|
||||
return False
|
||||
RPCExecute('model', self.model_name, 'write',
|
||||
[self.id], value, context=context)
|
||||
except RPCException:
|
||||
return False
|
||||
self._loaded.clear()
|
||||
@@ -352,8 +351,8 @@ class Record(SignalEvent):
|
||||
|
||||
def rec_name(self):
|
||||
try:
|
||||
return RPCExecute('model', self.model_name, 'read', self.id,
|
||||
['rec_name'], context=self.context_get())['rec_name']
|
||||
return RPCExecute('model', self.model_name, 'read', [self.id],
|
||||
['rec_name'], context=self.context_get())[0]['rec_name']
|
||||
except RPCException:
|
||||
return ''
|
||||
|
||||
@@ -533,7 +532,7 @@ class Record(SignalEvent):
|
||||
if fieldnames:
|
||||
try:
|
||||
result = RPCExecute('model', self.model_name, 'on_change_with',
|
||||
list(fieldnames), values, context=self.context_get())
|
||||
values, list(fieldnames), context=self.context_get())
|
||||
except RPCException:
|
||||
return
|
||||
for fieldname, value in result.items():
|
||||
|
||||
@@ -211,17 +211,17 @@ class TranslateDialog(NoModal):
|
||||
)
|
||||
try:
|
||||
value = RPCExecute('model', self.widget.record.model_name,
|
||||
'read', self.widget.record.id, [self.widget.field_name],
|
||||
'read', [self.widget.record.id], [self.widget.field_name],
|
||||
context={'language': language['code']}
|
||||
)[self.widget.field_name]
|
||||
)[0][self.widget.field_name]
|
||||
except RPCException:
|
||||
return
|
||||
context['fuzzy_translation'] = True
|
||||
try:
|
||||
fuzzy_value = RPCExecute('model',
|
||||
self.widget.record.model_name, 'read',
|
||||
self.widget.record.id, [self.widget.field_name],
|
||||
context=context)[self.widget.field_name]
|
||||
[self.widget.record.id], [self.widget.field_name],
|
||||
context=context)[0][self.widget.field_name]
|
||||
except RPCException:
|
||||
return
|
||||
widget = self.widget.translate_widget()
|
||||
@@ -276,7 +276,7 @@ class TranslateDialog(NoModal):
|
||||
)
|
||||
try:
|
||||
RPCExecute('model', self.widget.record.model_name, 'write',
|
||||
self.widget.record.id, {
|
||||
[self.widget.record.id], {
|
||||
self.widget.field_name: value,
|
||||
}, context=context)
|
||||
except RPCException:
|
||||
|
||||
Reference in new issue
Block a user