本文整理匯總了Python中rpc.RPCProxy.name_get方法的典型用法代碼示例。如果您正苦於以下問題:Python RPCProxy.name_get方法的具體用法?Python RPCProxy.name_get怎麽用?Python RPCProxy.name_get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rpc.RPCProxy
的用法示例。
在下文中一共展示了RPCProxy.name_get方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: set
# 需要導入模塊: from rpc import RPCProxy [as 別名]
# 或者: from rpc.RPCProxy import name_get [as 別名]
def set(self, model, value, test_state=False, modified=False):
if value and isinstance(value, (int, str, unicode, long)):
rpc2 = RPCProxy(self.attrs['relation'])
result = rpc2.name_get([value], rpc.session.context)
model.value[self.name] = result and result[0] or ''
else:
model.value[self.name] = value
if modified:
model.modified = True
model.modified_fields.setdefault(self.name)
示例2: ModelRecord
# 需要導入模塊: from rpc import RPCProxy [as 別名]
# 或者: from rpc.RPCProxy import name_get [as 別名]
#.........這裏部分代碼省略.........
value = self.get(get_readonly=False)
self.id = self.rpc.create(value, self.context_get())
if not self.id:
self.failed_validation()
else:
if not self.is_modified():
return self.id
value = self.get(get_readonly=False, get_modifiedonly=True)
context = self.context_get().copy()
self.update_context_with_concurrency_check_data(context)
if not self.rpc.write([self.id], value, context):
self.failed_validation()
return False
self._loaded = False
if reload:
self.reload()
else:
# just reload the CONCURRENCY_CHECK_FIELD
self._reload([CONCURRENCY_CHECK_FIELD])
return self.id
def default_get(self, domain=[], context={}):
if len(self.mgroup.fields):
val = self.rpc.default_get(self.mgroup.fields.keys(), context)
for d in domain:
if d[0] in self.mgroup.fields:
if d[1] == '=':
val[d[0]] = d[2]
if d[1] == 'in' and len(d[2]) == 1:
val[d[0]] = d[2][0]
self.set_default(val)
def name_get(self):
name = self.rpc.name_get([self.id], rpc.session.context)[0]
return name
def validate_set(self):
change = self._check_load()
for fname in self.mgroup.mfields:
field = self.mgroup.mfields[fname]
change = change or not field.get_state_attrs(self).get('valid', True)
field.get_state_attrs(self)['valid'] = True
if change:
self.signal('record-changed')
self.reload()
return change
def validate(self):
self._check_load()
ok = True
for fname in self.mgroup.mfields:
if not self.mgroup.mfields[fname].validate(self):
ok = False
return ok
def _get_invalid_fields(self):
res = []
for fname, field in self.mgroup.mfields.items():
if not field.get_state_attrs(self).get('valid', True):
res.append((fname, field.attrs['string']))
return dict(res)
invalid_fields = property(_get_invalid_fields)
def context_get(self):
return self.mgroup.context