本文整理汇总了Python中stoqlib.gui.search.searchfilters.ComboSearchFilter.get_state方法的典型用法代码示例。如果您正苦于以下问题:Python ComboSearchFilter.get_state方法的具体用法?Python ComboSearchFilter.get_state怎么用?Python ComboSearchFilter.get_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.gui.search.searchfilters.ComboSearchFilter
的用法示例。
在下文中一共展示了ComboSearchFilter.get_state方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PurchaseApp
# 需要导入模块: from stoqlib.gui.search.searchfilters import ComboSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.ComboSearchFilter import get_state [as 别名]
#.........这里部分代码省略.........
self.set_sensitive(self._inventory_widgets, False)
def create_filters(self):
self.set_text_field_columns(['supplier_name', 'identifier_str'])
self.status_filter = ComboSearchFilter(_('Show orders'),
self._get_status_values())
self.add_filter(self.status_filter, SearchFilterPosition.TOP, ['status'])
self.branch_filter = self.create_branch_filter(column=PurchaseOrderView.branch_id)
def get_columns(self):
return [IdentifierColumn('identifier', title=_('Purchase #')),
SearchColumn('status_str', title=_('Status'), width=100,
data_type=str, search_attribute='status',
valid_values=self._get_status_values(),
visible=False),
SearchColumn('open_date', title=_('Opened'),
long_title=_('Date Opened'), width=90,
data_type=datetime.date, sorted=True,
order=gtk.SORT_DESCENDING),
SearchColumn('supplier_name', title=_('Supplier'),
data_type=str, searchable=True, expand=True,
ellipsize=pango.ELLIPSIZE_END),
SearchColumn('ordered_quantity', title=_('Ordered'),
data_type=Decimal, width=90,
format_func=format_quantity),
SearchColumn('received_quantity', title=_('Received'),
data_type=Decimal, width=90,
format_func=format_quantity),
SearchColumn('total', title=_('Total'),
data_type=currency, width=120)]
def print_report(self, *args, **kwargs):
# PurchaseReport needs a status arg
kwargs['status'] = self.status_filter.get_state().value
super(PurchaseApp, self).print_report(*args, **kwargs)
def search_for_date(self, date):
dfilter = DateSearchFilter(_("Expected receival date"))
dfilter.set_removable()
dfilter.select(data=DateSearchFilter.Type.USER_DAY)
self.add_filter(dfilter, columns=["expected_receival_date"])
dfilter.start_date.set_date(date)
self.refresh()
#
# Private
#
def _update_totals(self):
self._update_view()
def _update_list_aware_widgets(self, has_items):
for widget in (self.Edit, self.Details):
widget.set_sensitive(has_items)
def _update_view(self):
self._update_list_aware_widgets(len(self.results))
selection = self.results.get_selected_rows()
can_edit = one_selected = len(selection) == 1
can_finish = False
if selection:
can_send_supplier = all(
order.status == PurchaseOrder.ORDER_PENDING
for order in selection)
can_cancel = all(order_view.purchase.can_cancel()
for order_view in selection)
示例2: ProductionApp
# 需要导入模块: from stoqlib.gui.search.searchfilters import ComboSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.ComboSearchFilter import get_state [as 别名]
#.........这里部分代码省略.........
self.check_open_inventory()
def deactivate(self):
self.uimanager.remove_ui(self.production_ui)
def new_activate(self):
self._open_production_order()
def search_activate(self):
self.run_dialog(ProductionProductSearch, self.store)
def create_filters(self):
self.set_text_field_columns(['description'])
self.status_filter = ComboSearchFilter(
_(u'Show productions with status'), self._get_status_values())
self.add_filter(self.status_filter, SearchFilterPosition.TOP, ['status'])
def get_columns(self):
return [IdentifierColumn('identifier', sorted=True,
order=gtk.SORT_DESCENDING),
Column('status_string', title=_(u'Status'), data_type=str,
visible=False),
SearchColumn('description', title=_(u'Description'),
data_type=str, expand=True),
Column('responsible.person.name', title=_(u'Responsible'),
data_type=str, width=150),
SearchColumn('open_date', title=_(u'Opened'),
data_type=datetime.date, width=80),
SearchColumn('close_date', title=_(u'Closed'),
data_type=datetime.date, width=80)]
def print_report(self, *args, **kwargs):
# ProductionReport needs a status kwarg
kwargs['status'] = self.status_filter.get_state().value
super(ProductionApp, self).print_report(*args, **kwargs)
def set_open_inventory(self):
self.set_sensitive(self._inventory_widgets, False)
#
# Private
#
def _update_widgets(self):
selected = self.results.get_selected()
can_edit = False
can_start = False
if selected:
can_edit = (selected.status == ProductionOrder.ORDER_OPENED or
selected.status == ProductionOrder.ORDER_WAITING)
can_start = can_edit
self.set_sensitive([self.EditProduction], can_edit)
self.set_sensitive([self.StartProduction], can_start)
self.set_sensitive([self.ProductionDetails], bool(selected))
def _get_status_values(self):
items = [(text, value)
for value, text in ProductionOrder.statuses.items()]
items.insert(0, (_(u'Any'), None))
return items
def _open_production_order(self, order=None):
store = api.new_store()
order = store.fetch(order)
retval = self.run_dialog(ProductionWizard, store, order)
store.confirm(retval)
示例3: BaseAccountWindow
# 需要导入模块: from stoqlib.gui.search.searchfilters import ComboSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.ComboSearchFilter import get_state [as 别名]
#.........这里部分代码省略.........
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()
#
# Callbacks
#
def _on_main_filter__row_separator_func(self, model, titer):
if model[titer][0] == 'sep':
return True
return False
def _on_results__cell_data_func(self, column, renderer, pv, text):
if not isinstance(renderer, Gtk.CellRendererText):
return text
state = self.main_filter.get_state()
def show_strikethrough():
if state.value is None:
return True
if state.value.value.startswith('category:'):
return True
return False
is_pending = (pv.status == Payment.STATUS_PENDING)
show_strikethrough = not is_pending and show_strikethrough()
is_late = pv.is_late()
renderer.set_property('strikethrough-set', show_strikethrough)
renderer.set_property('weight-set', is_late)
if show_strikethrough:
renderer.set_property('strikethrough', True)
if is_late:
renderer.set_property('weight', Pango.Weight.BOLD)
return text
def on_results__activate_link(self, results, uri):
if uri.startswith('new_payment'):
if '?' in uri:
category = urllib.parse.unquote(uri.split('?', 1)[1])
else:
category = None
self.add_payment(category=category)
def on_PaymentFlowHistory__activate(self, action):
self.run_dialog(PaymentFlowHistoryDialog, self.store)
def on_PaymentCategories__activate(self, action):
self._show_payment_categories()
示例4: StockApp
# 需要导入模块: from stoqlib.gui.search.searchfilters import ComboSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.ComboSearchFilter import get_state [as 别名]
#.........这里部分代码省略.........
self.branch_filter.select(api.get_current_branch(self.store))
self.add_filter(self.branch_filter, position=SearchFilterPosition.TOP)
def get_columns(self):
return [SearchColumn('code', title=_('Code'), sorted=True,
sort_func=sort_sellable_code,
data_type=str, width=130),
SearchColumn('barcode', title=_("Barcode"), data_type=str,
width=130),
SearchColumn('category_description', title=_("Category"),
data_type=str, width=100, visible=False),
SearchColumn('description', title=_("Description"),
data_type=str, expand=True,
ellipsize=pango.ELLIPSIZE_END),
SearchColumn('manufacturer', title=_("Manufacturer"),
data_type=str, visible=False),
SearchColumn('model', title=_("Model"),
data_type=str, visible=False),
SearchColumn('location', title=_("Location"), data_type=str,
width=100, visible=False),
SearchColumn('stock', title=_('Quantity'),
data_type=decimal.Decimal, width=100),
SearchColumn('unit', title=_("Unit"), data_type=str,
width=40, visible=False),
Column('has_image', title=_('Picture'),
data_type=bool, width=80),
]
#
# Private API
#
def _query(self, store):
branch = self.branch_filter.get_state().value
return self.search_table.find_by_branch(store, branch)
def _get_branches(self):
items = [(b.person.name, b)
for b in self.store.find(Branch)]
if not items:
raise DatabaseInconsistency('You should have at least one '
'branch on your database.'
'Found zero')
items.insert(0, [_('All branches'), None])
return items
def _update_widgets(self):
branch = api.get_current_branch(self.store)
is_main_branch = self.branch_filter.get_state().value is branch
item = self.results.get_selected()
sellable = item and item.product.sellable
if sellable:
if sellable.has_image:
thumbnail = sellable.image.thumbnail
pixbuf = self.pixbuf_converter.from_string(thumbnail)
else:
pixbuf = None
self._update_edit_image(pixbuf)
if self.image_viewer:
self.image_viewer.set_sellable(sellable)
else:
self._update_edit_image()
示例5: ProductionApp
# 需要导入模块: from stoqlib.gui.search.searchfilters import ComboSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.ComboSearchFilter import get_state [as 别名]
#.........这里部分代码省略.........
def activate(self, refresh=True):
if refresh:
self.refresh()
self._update_widgets()
self.check_open_inventory()
self.search.focus_search_entry()
def create_filters(self):
self.set_text_field_columns(['description'])
self.status_filter = ComboSearchFilter(
_(u'Show productions with status'), self._get_status_values())
self.add_filter(self.status_filter, SearchFilterPosition.TOP, ['status'])
def get_columns(self):
return [IdentifierColumn('identifier', title=_('Production #'), sorted=True,
order=Gtk.SortType.DESCENDING),
Column('status_string', title=_(u'Status'), data_type=str,
visible=False),
SearchColumn('description', title=_(u'Description'),
data_type=str, expand=True),
Column('responsible.person.name', title=_(u'Responsible'),
data_type=str, width=150),
SearchColumn('open_date', title=_(u'Opened'),
data_type=datetime.date, width=80),
SearchColumn('close_date', title=_(u'Closed'),
data_type=datetime.date, width=80),
SearchColumn('cancel_date', title=_(u'Cancelled'),
data_type=datetime.date, width=80)]
def print_report(self, *args, **kwargs):
# ProductionReport needs a status kwarg
kwargs['status'] = self.status_filter.get_state().value
super(ProductionApp, self).print_report(*args, **kwargs)
def set_open_inventory(self):
self.set_sensitive(self._inventory_widgets, False)
#
# Private
#
def _update_widgets(self):
selected = self.results.get_selected()
can_edit = False
can_start = False
can_finalize = False
can_cancel = False
if selected:
can_edit = (selected.status == ProductionOrder.ORDER_OPENED or
selected.status == ProductionOrder.ORDER_WAITING)
can_start = can_edit
can_finalize = (selected.status == ProductionOrder.ORDER_PRODUCING)
can_cancel = can_edit
self.set_sensitive([self.EditProduction], can_edit)
self.set_sensitive([self.StartProduction], can_start)
self.set_sensitive([self.FinalizeProduction], can_finalize)
self.set_sensitive([self.CancelProduction], can_cancel)
self.set_sensitive([self.ProductionDetails], bool(selected))
def _get_status_values(self):
items = [(text, value)
for value, text in ProductionOrder.statuses.items()]
items.insert(0, (_(u'Any'), None))
return items
示例6: StockApp
# 需要导入模块: from stoqlib.gui.search.searchfilters import ComboSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.ComboSearchFilter import get_state [as 别名]
#.........这里部分代码省略.........
data_type=str, visible=False),
SearchColumn('model', title=_("Model"),
data_type=str, visible=False),
SearchColumn('location', title=_("Location"), data_type=str,
width=100, visible=False),
QuantityColumn('stock', title=_('Quantity'), width=100,
use_having=True),
SearchColumn('has_image', title=_('Picture'),
data_type=bool, width=80),
]
#
# Private API
#
def _open_image_viewer(self):
assert self.image_viewer is None
self.image_viewer = SellableImageViewer(size=(325, 325))
self.image_viewer.toplevel.connect(
'delete-event', self.on_image_viewer_closed)
self.image_viewer.show_all()
self._update_widgets()
def _close_image_viewer(self):
if self.image_viewer is None:
return
self.image_viewer.destroy()
self.image_viewer = None
def _query(self, store):
branch = self.branch_filter.get_state().value
return self.search_spec.find_by_branch(store, branch)
def _update_widgets(self):
branch = api.get_current_branch(self.store)
is_main_branch = self.branch_filter.get_state().value is branch
item = self.results.get_selected()
sellable = item and item.product.sellable
if sellable:
if item.has_image:
thumbnail = sellable.image.thumbnail
pixbuf = self.pixbuf_converter.from_string(thumbnail)
else:
pixbuf = None
self._update_edit_image(pixbuf)
if self.image_viewer:
self.image_viewer.set_sellable(sellable)
else:
self._update_edit_image()
self.set_sensitive([self.EditProduct, self.PrintLabels], bool(item))
self.set_sensitive([self.ProductStockHistory],
bool(item) and is_main_branch)
# We need more than one branch to be able to do transfers
# Note that 'all branches' is not a real branch
has_branches = len(self.branch_filter.combo) > 2
transfer_active = self.NewTransfer.get_sensitive()
self.set_sensitive([self.NewTransfer],
transfer_active and has_branches)
示例7: ProductionApp
# 需要导入模块: from stoqlib.gui.search.searchfilters import ComboSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.ComboSearchFilter import get_state [as 别名]
#.........这里部分代码省略.........
self.refresh()
self._update_widgets()
self.check_open_inventory()
self.search.focus_search_entry()
def deactivate(self):
self.uimanager.remove_ui(self.production_ui)
def new_activate(self):
self._open_production_order()
def search_activate(self):
self.run_dialog(ProductionProductSearch, self.store)
def create_filters(self):
self.set_text_field_columns(["description"])
self.status_filter = ComboSearchFilter(_(u"Show productions with status"), self._get_status_values())
self.add_filter(self.status_filter, SearchFilterPosition.TOP, ["status"])
def get_columns(self):
return [
IdentifierColumn("identifier", sorted=True, order=gtk.SORT_DESCENDING),
Column("status_string", title=_(u"Status"), data_type=str, visible=False),
SearchColumn("description", title=_(u"Description"), data_type=str, expand=True),
Column("responsible.person.name", title=_(u"Responsible"), data_type=str, width=150),
SearchColumn("open_date", title=_(u"Opened"), data_type=datetime.date, width=80),
SearchColumn("close_date", title=_(u"Closed"), data_type=datetime.date, width=80),
SearchColumn("cancel_date", title=_(u"Cancelled"), data_type=datetime.date, width=80),
]
def print_report(self, *args, **kwargs):
# ProductionReport needs a status kwarg
kwargs["status"] = self.status_filter.get_state().value
super(ProductionApp, self).print_report(*args, **kwargs)
def set_open_inventory(self):
self.set_sensitive(self._inventory_widgets, False)
#
# Private
#
def _update_widgets(self):
selected = self.results.get_selected()
can_edit = False
can_start = False
can_finalize = False
can_cancel = False
if selected:
can_edit = (
selected.status == ProductionOrder.ORDER_OPENED or selected.status == ProductionOrder.ORDER_WAITING
)
can_start = can_edit
can_finalize = selected.status == ProductionOrder.ORDER_PRODUCING
can_cancel = can_edit
self.set_sensitive([self.EditProduction], can_edit)
self.set_sensitive([self.StartProduction], can_start)
self.set_sensitive([self.FinalizeProduction], can_finalize)
self.set_sensitive([self.CancelProduction], can_cancel)
self.set_sensitive([self.ProductionDetails], bool(selected))
def _get_status_values(self):
items = [(text, value) for value, text in ProductionOrder.statuses.items()]
items.insert(0, (_(u"Any"), None))
return items
示例8: StockApp
# 需要导入模块: from stoqlib.gui.search.searchfilters import ComboSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.ComboSearchFilter import get_state [as 别名]
#.........这里部分代码省略.........
data_type=str, visible=False),
SearchColumn('model', title=_("Model"),
data_type=str, visible=False),
SearchColumn('location', title=_("Location"), data_type=str,
width=100, visible=False),
QuantityColumn('stock', title=_('Quantity'), width=100,
use_having=True),
SearchColumn('has_image', title=_('Picture'),
data_type=bool, width=80),
]
#
# Private API
#
def _open_image_viewer(self):
assert self.image_viewer is None
self.image_viewer = SellableImageViewer(size=(325, 325))
self.image_viewer.toplevel.connect(
'delete-event', self.on_image_viewer_closed)
self.image_viewer.show_all()
self._update_widgets()
def _close_image_viewer(self):
if self.image_viewer is None:
return
self.image_viewer.destroy()
self.image_viewer = None
def _query(self, store):
branch = self.branch_filter.get_state().value
return self.search_spec.find_by_branch(store, branch)
def _update_widgets(self):
branch = api.get_current_branch(self.store)
is_main_branch = self.branch_filter.get_state().value is branch
item = self.results.get_selected()
sellable = item and item.product.sellable
if sellable:
if item.has_image:
# XXX:Workaround for a bug caused by the image domain refactoring
# which left some existent thumbnail as None
thumbnail = sellable.image.thumbnail
if thumbnail is None:
# Create new store to create the thumbnail
with api.new_store() as new_store:
image = sellable.image
image = new_store.fetch(image)
size = (Image.THUMBNAIL_SIZE_WIDTH, Image.THUMBNAIL_SIZE_HEIGHT)
image.thumbnail = get_thumbnail(image.image, size)
thumbnail = image.thumbnail
pixbuf = self.pixbuf_converter.from_string(thumbnail)
else:
pixbuf = None
self._update_edit_image(pixbuf)
if self.image_viewer:
self.image_viewer.set_sellable(sellable)
else:
self._update_edit_image()