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


Python Screen.get_domain方法代碼示例

本文整理匯總了Python中tryton.gui.window.view_form.screen.Screen.get_domain方法的典型用法代碼示例。如果您正苦於以下問題:Python Screen.get_domain方法的具體用法?Python Screen.get_domain怎麽用?Python Screen.get_domain使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tryton.gui.window.view_form.screen.Screen的用法示例。


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

示例1: One2Many

# 需要導入模塊: from tryton.gui.window.view_form.screen import Screen [as 別名]
# 或者: from tryton.gui.window.view_form.screen.Screen import get_domain [as 別名]

#.........這裏部分代碼省略.........
                record = None
            if not widget._validate():

                def go_previous():
                    record = widget.screen.current_record
                    if not is_compatbile(screen, record):
                        record = None
                    screen.current_record = record
                    screen.display()

                gobject.idle_add(go_previous)
                return
            to_sync.append((widget, record))
        for widget, record in to_sync:
            if (
                widget.screen.current_view.view_type == "form"
                and record is not None
                and widget.screen.group.model_name == record.group.model_name
            ):
                fields = dict((name, field.attrs) for name, field in widget.screen.group.fields.iteritems())
                record.group.load_fields(fields)
            widget.screen.current_record = record
            widget.display(widget.record, widget.field)

    def display(self, record, field):
        super(One2Many, self).display(record, field)

        self._set_button_sensitive()

        if field is None:
            self.screen.new_group()
            self.screen.current_record = None
            self.screen.parent = None
            self.screen.display()
            return False
        new_group = field.get_client(record)

        if self.attrs.get("group") and self.attrs.get("mode") == "form":
            if self.screen.current_record is None:
                self.invisible_set(True)
        elif id(self.screen.group) != id(new_group):
            self.screen.group = new_group
            if (self.screen.current_view.view_type == "tree") and self.screen.current_view.editable:
                self.screen.current_record = None
        readonly = False
        domain = []
        size_limit = None
        if record:
            readonly = field.get_state_attrs(record).get("readonly", False)
            domain = field.domain_get(record)
            size_limit = record.expr_eval(self.attrs.get("size"))
        if self.screen.get_domain() != domain:
            self.screen.domain = domain
        self.screen.group.readonly = readonly
        self.screen.size_limit = size_limit
        self.screen.display()
        return True

    def set_value(self, record, field):
        if (
            self.screen.current_view.view_type == "form"
            and self.attrs.get("group")
            and self.screen.model_name != record.model_name
        ):
            return True
        self.screen.current_view.set_value()
        if self.screen.modified():  # TODO check if required
            record.modified_fields.setdefault(field.name)
            record.signal("record-modified")
        return True

    def _completion_match_selected(self, completion, model, iter_):
        record_id, = model.get(iter_, 1)
        self.screen.load([record_id], modified=True)
        self.wid_text.set_text("")
        self.wid_text.grab_focus()

        completion_model = self.wid_completion.get_model()
        completion_model.clear()
        completion_model.search_text = self.wid_text.get_text()
        return True

    def _update_completion(self, widget):
        if self._readonly:
            return
        if not self.record:
            return
        model = self.attrs["relation"]
        domain = self.field.domain_get(self.record)
        domain = [domain, self.record.expr_eval(self.attrs.get("add_remove"))]
        removed_ids = self.field.get_removed_ids(self.record)
        domain = ["OR", domain, ("id", "in", removed_ids)]
        update_completion(self.wid_text, self.record, self.field, model, domain=domain)

    def _completion_action_activated(self, completion, index):
        if index == 0:
            self._sig_add()
            self.wid_text.grab_focus()
        elif index == 1:
            self._sig_new()
開發者ID:coopengo,項目名稱:tryton,代碼行數:104,代碼來源:one2many.py


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