当前位置: 首页>>代码示例>>Python>>正文


Python ComboSearchFilter.update_values方法代码示例

本文整理汇总了Python中stoqlib.gui.search.searchfilters.ComboSearchFilter.update_values方法的典型用法代码示例。如果您正苦于以下问题:Python ComboSearchFilter.update_values方法的具体用法?Python ComboSearchFilter.update_values怎么用?Python ComboSearchFilter.update_values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stoqlib.gui.search.searchfilters.ComboSearchFilter的用法示例。


在下文中一共展示了ComboSearchFilter.update_values方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MaintenanceApp

# 需要导入模块: from stoqlib.gui.search.searchfilters import ComboSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.ComboSearchFilter import update_values [as 别名]

#.........这里部分代码省略.........
                (self.Reopen, has_selected and wo.can_reopen()),
                # DeliverOrder is grouped here since it's a special case. Only
                # finished orders without items can be delivered here, so avoid
                # showing the option if it's not sensitive to avoid confusions
                (self.DeliverOrder, (has_selected and wo.can_close() and
                                     not wo.order_items.count()))]:
            self.set_sensitive([widget], value)
            # Some of those options are mutually exclusive (except Approve,
            # but it can only be called once) so avoid confusions and
            # hide not available options
            widget.set_visible(value)

    def _update_filters(self):
        options = [
            _FilterItem(_(u'Pending'), 'status:pending'),
            _FilterItem(_(u'In progress'), 'status:in-progress'),
            _FilterItem(_(u'Finished'), 'status:finished'),
            _FilterItem(_(u'Delivered or cancelled'), 'status:delivered'),
            _FilterItem('sep', 'sep'),
            _FilterItem(_(u'Approved'), 'flag:approved'),
            _FilterItem(_(u'In transport'), 'flag:in-transport'),
            _FilterItem(_(u'Rejected'), 'flag:rejected'),
        ]

        categories = list(self.store.find(WorkOrderCategory))
        if len(categories):
            options.append(_FilterItem('sep', 'sep'))
        for category in categories:
            value = 'category:%s' % (category.name, )
            options.append(_FilterItem(category.name, value,
                                       color=category.color,
                                       obj_id=category.id))

        self.main_filter.update_values(
            [(_(u'All work orders'), None)] +
            [(item.name, item) for item in options])

    def _new_order(self, category=None):
        with api.trans() as store:
            work_order = self.run_dialog(WorkOrderEditor, store,
                                         category=store.fetch(category))

        if store.committed:
            self._update_view(select_item=work_order)
            # A category may have been created on the editor
            self._update_filters()

    def _edit_order(self, work_order=None):
        if work_order is None:
            work_order = self.search.get_selected_item().work_order
        with api.trans() as store:
            self.run_dialog(WorkOrderEditor, store,
                            model=store.fetch(work_order))

        if store.committed:
            self._update_view()
            # A category may have been created on the editor
            self._update_filters()

    def _finish_order(self):
        if not yesno(_(u"This will finish the selected order, marking the "
                       u"work as done. Are you sure?"),
                     gtk.RESPONSE_NO, _(u"Finish order"), _(u"Don't finish")):
            return

        selection = self.search.get_selected_item()
开发者ID:rosalin,项目名称:stoq,代码行数:70,代码来源:maintenance.py

示例2: BaseAccountWindow

# 需要导入模块: from stoqlib.gui.search.searchfilters import ComboSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.ComboSearchFilter import update_values [as 别名]

#.........这里部分代码省略.........
            # We need to refresh the whole list as the payment(s) can possibly
            # disappear for the selected view
            self.refresh()

    def create_main_filter(self):
        self.main_filter = ComboSearchFilter(_('Show'), [])

        combo = self.main_filter.combo
        combo.color_attribute = 'color'
        combo.set_row_separator_func(self._on_main_filter__row_separator_func)
        self._update_filter_items()
        executer = self.search.get_query_executer()
        executer.add_filter_query_callback(
            self.main_filter,
            self._create_main_query)
        self.add_filter(self.main_filter, SearchFilterPosition.TOP)

        self.create_branch_filter(column=self.search_spec.branch_id)

    def add_filter_items(self, category_type, options):
        categories = PaymentCategory.get_by_type(self.store, category_type)
        items = [(_('All payments'), None)]

        if categories.count() > 0:
            options.append(FilterItem('sep', 'sep'))

        items.extend([(item.name, item) for item in options])
        for c in categories:
            item = FilterItem(c.name, 'category:%s' % (c.name, ),
                              color=c.color,
                              item_id=c.id)
            items.append((item.name, item))

        self.main_filter.update_values(items)

    #
    # Private
    #

    def _create_main_query(self, state):
        item = state.value
        if item is None:
            return None
        kind, value = item.value.split(':')
        payment_view = self.search_spec
        if kind == 'status':
            if value == 'paid':
                return payment_view.status == Payment.STATUS_PAID
            elif value == 'not-paid':
                return payment_view.status == Payment.STATUS_PENDING
            elif value == 'late':
                tolerance = api.sysparam.get_int('TOLERANCE_FOR_LATE_PAYMENTS')
                return And(
                    payment_view.status == Payment.STATUS_PENDING,
                    payment_view.due_date < localtoday() -
                    relativedelta(days=tolerance))
        elif kind == 'category':
            return payment_view.category == value

        raise AssertionError(kind, value)

    def _show_payment_categories(self):
        store = api.new_store()
        self.run_dialog(PaymentCategoryDialog, store, self.payment_category_type)
        self._update_filter_items()
        store.close()
开发者ID:hackedbellini,项目名称:stoq,代码行数:70,代码来源:accounts.py

示例3: ServicesApp

# 需要导入模块: from stoqlib.gui.search.searchfilters import ComboSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.ComboSearchFilter import update_values [as 别名]

#.........这里部分代码省略.........
        finish_btn = self.window.domain_header.get_children()[2]
        finish_btn.set_tooltip_text(_(u"Finish"))
        # If the selected work order is already finished, we change the finish
        # button's label.
        if wo and wo.status == WorkOrder.STATUS_WORK_FINISHED:
            finish_btn.set_tooltip_text(_(u"Deliver"))

    def _update_filters(self):
        self._not_delivered_filter_item = _FilterItem(_(u'Not delivered'),
                                                      'status:not-delivered')
        options = [
            self._not_delivered_filter_item,
            _FilterItem(_(u'Pending'), 'status:pending'),
            _FilterItem(_(u'In progress'), 'status:in-progress'),
            _FilterItem(_(u'Finished'), 'status:finished'),
            _FilterItem(_(u'Delivered'), 'status:delivered'),
            _FilterItem(_(u'Cancelled'), 'status:cancelled'),
            _FilterItem(_(u'All work orders'), 'status:all-orders'),
            _FilterItem('sep', 'sep'),
            _FilterItem(_(u'Approved'), 'flag:approved'),
            _FilterItem(_(u'In transport'), 'flag:in-transport'),
            _FilterItem(_(u'Rejected'), 'flag:rejected'),
        ]

        categories = list(self.store.find(WorkOrderCategory))
        if len(categories):
            options.append(_FilterItem('sep', 'sep'))
        for category in categories:
            value = 'category:%s' % (category.name, )
            options.append(_FilterItem(category.name, value,
                                       color=category.color,
                                       obj_id=category.id))

        self.main_filter.update_values(
            [(item.name, item) for item in options])

    def _run_order_category_dialog(self):
        with api.new_store() as store:
            self.run_dialog(WorkOrderCategoryDialog, store)
        self._update_view()
        self._update_filters()

    #
    # Kiwi Callbacks
    #

    def _on_main_filter__row_separator_func(self, model, titer):
        obj = model[titer][1]
        if obj and obj.value == 'sep':
            return True
        return False

    def _on_results__cell_data_func(self, column, renderer, wov, text):
        if not isinstance(renderer, Gtk.CellRendererText):
            return text

        work_order = wov.work_order
        is_finished = work_order.status == WorkOrder.STATUS_WORK_FINISHED
        is_delivered = work_order.status in [WorkOrder.STATUS_CANCELLED,
                                             WorkOrder.STATUS_DELIVERED]
        is_late = work_order.is_late()

        for prop, is_set, value in [
                ('strikethrough', is_delivered, True),
                ('style', is_finished, Pango.Style.ITALIC),
                ('weight', is_late, Pango.Weight.BOLD)]:
开发者ID:hackedbellini,项目名称:stoq,代码行数:70,代码来源:services.py


注:本文中的stoqlib.gui.search.searchfilters.ComboSearchFilter.update_values方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。