當前位置: 首頁>>代碼示例>>Python>>正文


Python rpc.RPCProxy類代碼示例

本文整理匯總了Python中rpc.RPCProxy的典型用法代碼示例。如果您正苦於以下問題:Python RPCProxy類的具體用法?Python RPCProxy怎麽用?Python RPCProxy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了RPCProxy類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: cond_default

 def cond_default(self, field, value):
     ir = RPCProxy('ir.values')
     values = ir.get('default', '%s=%s' % (field, value),
                     [(self.resource, False)], False, {})
     data = {}
     for index, fname, value in values:
         data[fname] = value
     self.set_default(data)
開發者ID:gisce,項目名稱:erpclient,代碼行數:8,代碼來源:record.py

示例2: cond_default

 def cond_default(self, field, value):
     if field in self.mgroup.mfields:
         if self.mgroup.mfields[field].attrs.get("change_default", False):
             ir = RPCProxy("ir.values")
             values = ir.get("default", "%s=%s" % (field, value), [(self.resource, False)], False, {})
             data = {}
             for index, fname, value in values:
                 data[fname] = value
             self.set_default(data)
開發者ID:platformerp,項目名稱:PlatformERP-GTK-Client,代碼行數:9,代碼來源:record.py

示例3: set

 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)
開發者ID:kevin-garnett,項目名稱:openerp-from-oneyoung,代碼行數:10,代碼來源:field.py

示例4: set

 def set(self, model, value, modified=False):
     ## The case where M2M may appear in a domain as string
     ## eg: if I have a domain on partner list view as
     ## [('categ_id','=','supplier')]
     if value and isinstance(value[0], (str, unicode)):
         rpc2 = RPCProxy(self.attrs["relation"])
         result = []
         for val in value:
             result += rpc2.name_search(val, [], "=", rpc.session.context)
         value = map(lambda x: x[0], result)
     model.value[self.name] = value and value[: self.limit] or []
     model.pager_cache[self.name] = value or []
     if modified:
         model.modified = True
         model.modified_fields.setdefault(self.name)
開發者ID:goldenboy,項目名稱:razvoj,代碼行數:15,代碼來源:field.py

示例5: set_default

    def set_default(self, model, value):
        from widget.model.group import ModelRecordGroup
        fields = {}
        if value and len(value):
            context = self.context_get(model)
            rpc2 = RPCProxy(self.attrs['relation'])
            fields = rpc2.fields_get(value[0].keys(), context)

        model.value[self.name] = ModelRecordGroup(resource=self.attrs['relation'], fields=fields, parent=model)
        model.value[self.name].signal_connect(model.value[self.name], 'model-changed', self._model_changed)
        mod=None
        for record in (value or []):
            mod = model.value[self.name].model_new(default=False)
            mod.set_default(record)
            model.value[self.name].model_add(mod)
        model.value[self.name].current_model = mod
        #mod.signal('record-changed')
        return True
開發者ID:gisce,項目名稱:erpclient,代碼行數:18,代碼來源:field.py

示例6: __handle_register

class _CmdHandler:

    def __handle_register(self):
        self.proxy.register_entity(self.options.id,
                                   _config_from_opts(self.options))

    def __handle_unregister(self):
        self.proxy.unregister_entity(self.options.id)

    def __handle_set_config(self):
        cfg = self.proxy.get_entity_config(self.options.id)
        self.proxy.set_entity_config(self.options.id,
                                     _config_from_opts(self.options,
                                                       default=cfg))

    def __handle_get_config(self):
        print self.proxy.get_entity_config(self.options.id)

    def __handle_list(self):
        for id, cfg in self.proxy.get_entities():
            print "%s <%s>" % (id, cfg)

    __handlers = {
        "register":     __handle_register,
        "unregister":   __handle_unregister,
        "set_config":   __handle_set_config,
        "get_config":   __handle_get_config,
        "list":         __handle_list,
    }

    def __init__(self, cmdname, options):
        self.proxy = RPCProxy()
        self.cmdname = cmdname
        self.options = options

    def __nonzero__(self):
        return self.cmdname in self.__handlers

    def handle(self):
        self.proxy.connect(self.options.socket)
        try:
            self.__handlers[self.cmdname](self)
        finally:
            self.proxy.disconnect()
開發者ID:carriercomm,項目名稱:vcmmd,代碼行數:44,代碼來源:cli.py

示例7: __init__

 def __init__(self, resource, id, group=None, parent=None, new=False ):
     super(ModelRecord, self).__init__()
     self.resource = str(resource)
     self.rpc = RPCProxy(self.resource)
     self.id = id
     self._loaded = False
     self.parent = parent
     self.mgroup = group
     self.value = {}
     self.state_attrs = {}
     self.modified = False
     self.modified_fields = {}
     self._concurrency_check_data = False
     for key,val in self.mgroup.mfields.items():
         self.value[key] = val.create(self)
         if (new and val.attrs['type']=='one2many') and (val.attrs.get('mode','tree,form').startswith('form')):
             mod = self.value[key].model_new()
             self.value[key].model_add(mod)
開發者ID:gisce,項目名稱:erpclient,代碼行數:18,代碼來源:record.py

示例8: __init__

    def __init__(self, resource, fields, ids=[], parent=None, context={}, is_wizard=False):
        super(ModelRecordGroup, self).__init__()
        self._readonly = False
        self.parent = parent
        self._context = context
        self._context.update(rpc.session.context)
        self.resource = resource
        self.rpc = RPCProxy(resource)
        self.fields = fields
        self.mfields = {}
        self.mfields_load(fields.keys(), self)

        self.models = ModelList(self)
        self.current_idx = None

        self.load(ids)
        self.models_removed = []
        self.on_write = ''
        self.is_wizard = is_wizard
開發者ID:gisce,項目名稱:erpclient,代碼行數:19,代碼來源:group.py

示例9: __init__

 def __init__(self, resource, id, group=None, parent=None, new=False, list_parent=None):
     super(ModelRecord, self).__init__()
     self.resource = str(resource)
     self.rpc = RPCProxy(self.resource)
     self.id = id
     self.list_parent = list_parent
     self._loaded = False
     self.parent = parent
     self.mgroup = group
     self.value = {}
     self.state_attrs = {}
     self.modified = False
     self.modified_fields = {}
     self.pager_cache = {}
     self.is_m2m_modified = False
     self._concurrency_check_data = False
     for key, val in self.mgroup.mfields.items():
         self.value[key] = val.create(self)
         if (new and val.attrs["type"] == "one2many") and (val.attrs.get("mode", "tree,form").startswith("form")):
             mod = self.value[key].model_new()
             self.value[key].model_add(mod)
開發者ID:platformerp,項目名稱:PlatformERP-GTK-Client,代碼行數:21,代碼來源:record.py

示例10: __init__

    def __init__(self, model_name, view_ids=None, view_type=None,
            parent=None, context=None, views_preload=None, tree_saves=True,
            domain=None, create_new=False, row_activate=None, hastoolbar=False,
            default_get=None, show_search=False, window=None, limit=80,
            readonly=False, is_wizard=False):
        if view_ids is None:
            view_ids = []
        if view_type is None:
            view_type = ['tree', 'form']
        if context is None:
            context = {}
        if views_preload is None:
            views_preload = {}
        if domain is None:
            domain = []
        if default_get is None:
            default_get = {}

        super(Screen, self).__init__()

        self.show_search = show_search
        self.search_count = 0
        self.hastoolbar = hastoolbar
        self.default_get=default_get
        if not row_activate:
            self.row_activate = lambda self,screen=None: self.switch_view(screen, 'form')
        else:
            self.row_activate = row_activate
        self.create_new = create_new
        self.name = model_name
        self.domain = domain
        self.latest_search = []
        self.views_preload = views_preload
        self.resource = model_name
        self.rpc = RPCProxy(model_name)
        self.context = context
        self.context.update(rpc.session.context)
        self.views = []
        self.fields = {}
        self.view_ids = view_ids
        self.models = None
        self.parent=parent
        self.window=window
        self.is_wizard = is_wizard
        models = ModelRecordGroup(model_name, self.fields, parent=self.parent, context=self.context, is_wizard=is_wizard)
        self.models_set(models)
        self.current_model = None
        self.screen_container = screen_container()
        self.filter_widget = None
        self.widget = self.screen_container.widget_get()
        self.__current_view = 0
        self.tree_saves = tree_saves
        self.limit = limit
        self.readonly= readonly
        self.view_fields = {} # Used to switch self.fields when the view switchs

        if view_type:
            self.view_to_load = view_type[1:]
            view_id = False
            if view_ids:
                view_id = view_ids.pop(0)
            view = self.add_view_id(view_id, view_type[0])
            self.screen_container.set(view.widget)
        self.display()
開發者ID:gisce,項目名稱:erpclient,代碼行數:64,代碼來源:screen.py

示例11: ModelRecord

class ModelRecord(signal_event.signal_event):
    def __init__(self, resource, id, group=None, parent=None, new=False, list_parent=None):
        super(ModelRecord, self).__init__()
        self.resource = str(resource)
        self.rpc = RPCProxy(self.resource)
        self.id = id
        self.list_parent = list_parent
        self._loaded = False
        self.parent = parent
        self.mgroup = group
        self.value = {}
        self.state_attrs = {}
        self.modified = False
        self.modified_fields = {}
        self.pager_cache = {}
        self.is_m2m_modified = False
        self._concurrency_check_data = False
        for key, val in self.mgroup.mfields.items():
            self.value[key] = val.create(self)
            if (new and val.attrs['type']=='one2many') and (val.attrs.get('mode', 'tree,form').startswith('form')):
                mod = self.value[key].model_new()
                self.value[key].model_add(mod)


    def __getitem__(self, name):
        return self.mgroup.mfields.get(name, False)

    def __repr__(self):
        return '<ModelRecord %[email protected]%s>' % (self.id, self.resource)

    def is_modified(self):
        return self.modified

    def is_wizard(self):
        return self.mgroup.is_wizard

    def fields_get(self):
        return self.mgroup.mfields

    def _check_load(self):
        if not self._loaded:
            self.reload()
            return True
        return False

    def update_context_with_concurrency(self, context):
        if self.id and self.is_modified():
            context.setdefault(CONCURRENCY_CHECK_FIELD, {})["%s,%s" % (self.resource, self.id)] = self._concurrency_check_data
        for name, field in self.mgroup.mfields.items():
            if isinstance(field, O2MField):
                v = self.value[field.name]
                from itertools import chain
                for m in chain(v.models, v.models_removed):
                    m.update_context_with_concurrency(context)

    def get(self, get_readonly=True, includeid=False, check_load=True, get_modifiedonly=False):
        if check_load:
            self._check_load()
        value = []
        for name, field in self.mgroup.mfields.items():
            if (get_readonly or not field.get_state_attrs(self).get('readonly', False)) \
                and (not get_modifiedonly or (field.name in self.modified_fields or isinstance(field, O2MField))):
                    value.append((name, field.get(self, readonly=get_readonly,
                        modified=get_modifiedonly)))
        value = dict(value)
        if includeid:
            value['id'] = self.id
        return value

    def cancel(self):
        self._loaded = False
        self.reload()

    def failed_validation(self):
        invalid_fields = self.rpc.get_invalid_fields()
        for item in invalid_fields:
           if item in self.mgroup.mfields:
               self.mgroup.mfields[item].get_state_attrs(self)['valid'] = False

    def save(self, reload=True):
        self._check_load()
        try:
            if not self.id:
                value = self.get(get_readonly=False)
                self.id = self.rpc.create(value, self.context_get())
            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(context)
                res = self.rpc.write([self.id], value, context)
                if type(res)==type({}):
                    obj = service.LocalService('action.main')
                    obj._exec_action(res,{}, context)
        except Exception, e:
            if hasattr(e, 'faultCode') and e.faultCode.find('ValidateError')>-1:
                self.failed_validation()
                return False
            pass
#.........這裏部分代碼省略.........
開發者ID:kevin-garnett,項目名稱:openerp-from-oneyoung,代碼行數:101,代碼來源:record.py

示例12: __init__

    def __init__(self, model_name, view_ids=None, view_type=None,help={},
            parent=None, context=None, views_preload=None, tree_saves=True,
            domain=None, create_new=False, row_activate=None, hastoolbar=False,
            hassubmenu=False,default_get=None, show_search=False, window=None,
            limit=100, readonly=False, auto_search=True, is_wizard=False, search_view=None,win_search=False):
        if view_ids is None:
            view_ids = []
        if view_type is None:
            view_type = ['tree', 'form']
        if views_preload is None:
            views_preload = {}
        if not domain:
            domain = []
        if default_get is None:
            default_get = {}
        if search_view is None:
            search_view = "{}"

        super(Screen, self).__init__()
        self.win_search = win_search
        self.win_search_domain = []
        self.win_search_ids = []
        self.win_search_callback = False
        self.show_search = show_search
        self.auto_search = auto_search
        self.search_count = 0
        self.hastoolbar = hastoolbar
        self.hassubmenu = hassubmenu
        self.default_get=default_get
        self.sort = False
        self.type = None
        self.dummy_cal = False
        self.openerp_widgets = {'form':[ 'date','time','datetime','float','integer','selection','char','float_time',
                                        'boolean','button','reference','binary','picture','text','text_wiki','text_tag',
                                        'one2many','one2many_form','one2many_list','many2many','many2one','email','url',
                                        'callto','sip','image','uri','progressbar'],
                                'tree':['char','many2one','date','one2many','many2many','selection','float','float_time','integer',
                                        'datetime','boolean','progressbar','button']}
        if not row_activate:
            self.row_activate = lambda self,screen=None: self.switch_view(screen, 'form')
        else:
            self.row_activate = row_activate
        self.create_new = create_new
        self.name = model_name
        self.domain_init = domain
        self.action_domain = []
        self.action_domain += domain
        self.latest_search = []
        self.views_preload = views_preload
        self.resource = model_name
        self.rpc = RPCProxy(model_name)
        self.context_init = context or {}
        self.context_update()
        self.views = []
        self.fields = {}
        self.view_ids = view_ids
        self.models = None
        self.parent=parent
        self.window=window
        self.is_wizard = is_wizard
        self.search_view = eval(search_view)
        models = ModelRecordGroup(model_name, self.fields, parent=self.parent, context=self.context, is_wizard=is_wizard, screen=self)
        self.models_set(models)
        self.current_model = None
        self.screen_container = screen_container(self.win_search)
        self.filter_widget = None
        self.widget = self.screen_container.widget_get()
        self.__current_view = 0
        self.tree_saves = tree_saves
        self.limit = limit
        self.old_limit = limit
        self.offset = 0
        self.readonly= readonly
        self.view_fields = {} # Used to switch self.fields when the view switchs
        self.sort_domain = []
        self.old_ctx = {}
        self.help_mode = False
        if view_type:
            self.view_to_load = view_type[1:]
            view_id = False
            if view_ids:
                view_id = view_ids.pop(0)
            if view_type[0] in ('tree','graph','calendar'):
                self.screen_container.help = help
                self.help_mode = view_type[0]
            view = self.add_view_id(view_id, view_type[0], help=help)
            self.screen_container.set(view.widget)
        self.display()
開發者ID:Ichag,項目名稱:openerp-client,代碼行數:88,代碼來源:screen.py

示例13: Screen

class Screen(signal_event.signal_event):

    def __init__(self, model_name, view_ids=None, view_type=None,help={},
            parent=None, context=None, views_preload=None, tree_saves=True,
            domain=None, create_new=False, row_activate=None, hastoolbar=False,
            hassubmenu=False,default_get=None, show_search=False, window=None,
            limit=100, readonly=False, auto_search=True, is_wizard=False, search_view=None,win_search=False):
        if view_ids is None:
            view_ids = []
        if view_type is None:
            view_type = ['tree', 'form']
        if views_preload is None:
            views_preload = {}
        if not domain:
            domain = []
        if default_get is None:
            default_get = {}
        if search_view is None:
            search_view = "{}"

        super(Screen, self).__init__()
        self.win_search = win_search
        self.win_search_domain = []
        self.win_search_ids = []
        self.win_search_callback = False
        self.show_search = show_search
        self.auto_search = auto_search
        self.search_count = 0
        self.hastoolbar = hastoolbar
        self.hassubmenu = hassubmenu
        self.default_get=default_get
        self.sort = False
        self.type = None
        self.dummy_cal = False
        self.openerp_widgets = {'form':[ 'date','time','datetime','float','integer','selection','char','float_time',
                                        'boolean','button','reference','binary','picture','text','text_wiki','text_tag',
                                        'one2many','one2many_form','one2many_list','many2many','many2one','email','url',
                                        'callto','sip','image','uri','progressbar'],
                                'tree':['char','many2one','date','one2many','many2many','selection','float','float_time','integer',
                                        'datetime','boolean','progressbar','button']}
        if not row_activate:
            self.row_activate = lambda self,screen=None: self.switch_view(screen, 'form')
        else:
            self.row_activate = row_activate
        self.create_new = create_new
        self.name = model_name
        self.domain_init = domain
        self.action_domain = []
        self.action_domain += domain
        self.latest_search = []
        self.views_preload = views_preload
        self.resource = model_name
        self.rpc = RPCProxy(model_name)
        self.context_init = context or {}
        self.context_update()
        self.views = []
        self.fields = {}
        self.view_ids = view_ids
        self.models = None
        self.parent=parent
        self.window=window
        self.is_wizard = is_wizard
        self.search_view = eval(search_view)
        models = ModelRecordGroup(model_name, self.fields, parent=self.parent, context=self.context, is_wizard=is_wizard, screen=self)
        self.models_set(models)
        self.current_model = None
        self.screen_container = screen_container(self.win_search)
        self.filter_widget = None
        self.widget = self.screen_container.widget_get()
        self.__current_view = 0
        self.tree_saves = tree_saves
        self.limit = limit
        self.old_limit = limit
        self.offset = 0
        self.readonly= readonly
        self.view_fields = {} # Used to switch self.fields when the view switchs
        self.sort_domain = []
        self.old_ctx = {}
        self.help_mode = False
        if view_type:
            self.view_to_load = view_type[1:]
            view_id = False
            if view_ids:
                view_id = view_ids.pop(0)
            if view_type[0] in ('tree','graph','calendar'):
                self.screen_container.help = help
                self.help_mode = view_type[0]
            view = self.add_view_id(view_id, view_type[0], help=help)
            self.screen_container.set(view.widget)
        self.display()

    def context_update(self, ctx={}, dmn=[]):
        self.context = self.context_init.copy()
        self.context.update(rpc.session.context)
        self.context.update(ctx)
        self.domain = self.domain_init[:]
        self.domain += dmn


    def readonly_get(self):
#.........這裏部分代碼省略.........
開發者ID:Ichag,項目名稱:openerp-client,代碼行數:101,代碼來源:screen.py

示例14: ModelRecordGroup

class ModelRecordGroup(signal_event.signal_event):
    def __init__(self, resource, fields, ids=[], parent=None, context={}, is_wizard=False, screen=None):
        super(ModelRecordGroup, self).__init__()
        self._readonly = False
        self.parent = parent
        self._context = context
        self._context.update(rpc.session.context)
        self.resource = resource
        self.rpc = RPCProxy(resource)
        self.fields = fields
        self.mfields = {}
        self.mfields_load(fields.keys(), self)
        self.screen = screen

        self.models = ModelList(self)
        self.current_idx = None

        self.load(ids)
        self.models_removed = []
        self.on_write = ''
        self.is_wizard = is_wizard

        self.list_parent = False
        self.list_group = False

    def destroy(self):
        for field in self.mfields.values():
            field.destroy()
        if self.list_group:
            self.list_group.destroy()
        del self.mfields
        del self.fields
        del self.list_group
        del self.models

    def index(self, model):
        return self.models.index(model)

    def mfields_load(self, fkeys, models):
        for fname in fkeys:
            fvalue = models.fields[fname]
            modelfield = field.ModelField(fvalue['type'])
            fvalue['name'] = fname
            models.mfields[fname] = modelfield(models, fvalue)

    def model_move(self, model, position=0):
        self.models.move(model, position)

    def set_sequence(self, get_id, rec_id, field='sequence'):
        seq_ids = []
        index = 0
        for model in self.models:
             seq_ids += [model[field].get(model)]
             index = index +1

        set_list = list(set(seq_ids))
        if len(seq_ids) != len(set_list):
            set_list.sort()
            repeat = set_list[-1]
            mod_list = seq_ids[len(set_list):]
            for e in range(len(mod_list)):
                repeat = repeat + 1
                mod_list[e]= repeat
            final_list = set_list + mod_list

            index = 0
            for model in self.models:
                model[field].set(model, final_list[index], modified=True)
                if model.id:
                    model.save()
                index = index +1
        else:
            seq_id = []
            if get_id < rec_id:
                for x in range(get_id, rec_id):
                        seq_id += [self.models[x][field].get(self.models[x])]
                sort_seq = [seq_id[-1]] + seq_id[:-1]
                index = 0
                for x in range(get_id, rec_id):
                    self.models[x][field].set(self.models[x], sort_seq[index], modified=True)
                    if self.models[x].id:
                        self.models[x].save()
                    index = index +1
            else:
                for x in range(rec_id,get_id+1):
                    seq_id  += [self.models[x][field].get(self.models[x])]
                sort_seq = seq_id[1:] + [seq_id[0]]
                index = 0
                for x in range(rec_id,get_id+1):
                    self.models[x][field].set(self.models[x], sort_seq[index], modified=True)
                    if self.models[x].id:
                        self.models[x].save()
                    index = index +1


    def save(self):
        for model in self.models:
            saved = model.save()
            self.writen(saved)

#.........這裏部分代碼省略.........
開發者ID:goldenboy,項目名稱:razvoj,代碼行數:101,代碼來源:group.py

示例15: __init__

 def __init__(self, cmdname, options):
     self.proxy = RPCProxy()
     self.cmdname = cmdname
     self.options = options
開發者ID:carriercomm,項目名稱:vcmmd,代碼行數:4,代碼來源:cli.py


注:本文中的rpc.RPCProxy類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。