Exemplo n.º 1
0
 def set(self, record, value, test_state=False, modified=False):
     if not value:
         record.values[self.name] = False
         return
     ref_model, ident = value.split(',')
     Rpc2 = RpcProxy(ref_model)
     result = Rpc2.name_get([int(ident)], Rpc.session.context)
     if result:
         record.values[self.name] = ref_model, result[0]
     else:
         record.values[self.name] = False
     if modified:
         record.modified = True
         record.modified_fields.setdefault(self.name)
Exemplo n.º 2
0
    def set(self, record, value, test_state=False, modified=False):
        if value and isinstance(value, (int, str)):
            Rpc2 = RpcProxy(self.attrs['relation'])
            result = Rpc2.name_get([value], Rpc.session.context)

            # In some very rare cases we may get an empty
            # list from the server so we just check it before
            # trying to store result[0]
            if result:
                record.values[self.name] = result[0]
        else:
            record.values[self.name] = value
        if modified:
            record.modified = True
            record.modified_fields.setdefault(self.name)
Exemplo n.º 3
0
    def set(self, record, 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)

            # In some very rare cases we may get an empty
            # list from the server so we just check it before
            # trying to store result[0]
            if result:
                assert isinstance(result[0], (tuple, list)), result[0]
                record.values[self.name] = tuple(result[0])
        elif isinstance(value, dict):
            record.values[self.name] = (value['id'], value.get('name', False))
        else:
            record.values[self.name] = value
        if modified:
            record.modified = True
            record.modified_fields.setdefault(self.name)