本文整理汇总了Python中stoqlib.gui.search.searchfilters.DateSearchFilter.select方法的典型用法代码示例。如果您正苦于以下问题:Python DateSearchFilter.select方法的具体用法?Python DateSearchFilter.select怎么用?Python DateSearchFilter.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.gui.search.searchfilters.DateSearchFilter
的用法示例。
在下文中一共展示了DateSearchFilter.select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProductsSoldSearch
# 需要导入模块: from stoqlib.gui.search.searchfilters import DateSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.DateSearchFilter import select [as 别名]
class ProductsSoldSearch(ProductSearch):
title = _('Products Sold Search')
search_spec = SoldItemView
report_class = ProductsSoldReport
csv_data = None
has_print_price_button = False
advanced_search = False
text_field_columns = [SoldItemView.description]
branch_filter_column = Sale.branch_id
def __init__(self, store, hide_footer=True, hide_toolbar=True):
ProductSearch.__init__(self, store, hide_footer=hide_footer,
hide_toolbar=hide_toolbar)
#
# ProductSearch
#
def create_filters(self):
self.date_filter = DateSearchFilter(_('Date:'))
self.date_filter.select(Today)
self.add_filter(self.date_filter, columns=[Sale.confirm_date])
def get_columns(self):
return [Column('code', title=_('Code'), data_type=str,
sorted=True),
Column('description', title=_('Description'),
data_type=str, expand=True),
QuantityColumn('quantity', title=_('Sold')),
Column('average_cost', title=_('Avg. Cost'),
data_type=currency), ]
示例2: add_filter_by_attribute
# 需要导入模块: from stoqlib.gui.search.searchfilters import DateSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.DateSearchFilter import select [as 别名]
def add_filter_by_attribute(self, attr, title, data_type, valid_values=None,
callback=None, use_having=False,
multiple_selection=False):
"""Add a filter accordingly to the attributes specified
:param attr: attribute that will be filtered. This can be either the
name of the attribute or the attribute itself.
:param title: the title of the filter that will be visible in the
interface
:param data_type: the attribute type (str, bool, decimal, etc)
:param callback: the callback function that will be triggered
:param use_having: use having expression in the query
"""
if data_type is not bool:
title += ':'
if data_type == datetime.date:
filter = DateSearchFilter(title)
if valid_values:
filter.clear_options()
filter.add_custom_options()
for opt in valid_values:
filter.add_option(opt)
filter.select(valid_values[0])
elif (data_type == decimal.Decimal or
data_type == int or
data_type == currency):
filter = NumberSearchFilter(title)
if data_type != int:
filter.set_digits(2)
elif data_type == str:
if multiple_selection:
assert valid_values, "need valid_values for multiple_selection"
filter = MultiSearchFilter(title, valid_values)
elif valid_values:
filter = ComboSearchFilter(title, valid_values)
filter.enable_advanced()
else:
filter = StringSearchFilter(title)
filter.enable_advanced()
elif data_type == bool:
filter = BoolSearchFilter(title)
else:
raise NotImplementedError(title, data_type)
filter.set_removable()
self.add_filter(filter, columns=[attr],
callback=callback,
use_having=use_having)
if data_type is not bool:
label = filter.get_title_label()
label.set_alignment(1.0, 0.5)
self.label_group.add_widget(label)
combo = filter.get_mode_combo()
if combo:
self.combo_group.add_widget(combo)
return filter
示例3: MedicSalesSearch
# 需要导入模块: from stoqlib.gui.search.searchfilters import DateSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.DateSearchFilter import select [as 别名]
class MedicSalesSearch(SearchDialog):
title = _(u"Sold Items by medic")
size = (800, 450)
search_spec = MedicSoldItemsView
fast_iter = True
#
# SearchDialog Hooks
#
def setup_widgets(self):
self.add_csv_button(_("Sold Products"), _("sold-products"))
self.sale_details_button = self.add_button(label=_("Sale Details"))
self.sale_details_button.show()
self.sale_details_button.set_sensitive(False)
def update_widgets(self):
item = self.results.get_selected()
self.sale_details_button.set_sensitive(bool(item))
def create_filters(self):
self.set_text_field_columns(["medic_name", "description", "code"])
# Dont set a limit here, otherwise it might break the summary
executer = self.search.get_query_executer()
executer.set_limit(-1)
branch_filter = self.create_branch_filter(_("In Branch:"))
self.add_filter(branch_filter, SearchFilterPosition.TOP, columns=[Sale.branch_id])
self._date_filter = DateSearchFilter(_("Date:"))
self._date_filter.select(data=DateSearchFilter.Type.USER_INTERVAL)
self.add_filter(self._date_filter, SearchFilterPosition.BOTTOM, columns=[Sale.confirm_date])
self.search.set_summary_label("total", label=_(u"Total:"), format="<b>%s</b>")
def get_columns(self):
columns = [
IdentifierColumn("identifier", title=_("Sale #")),
SearchColumn("open_date", title=_("Open date"), data_type=datetime.date, visible=False),
SearchColumn("confirm_date", title=_("Confirm date"), data_type=datetime.date, visible=False),
SearchColumn("code", title=_("Code"), data_type=str, sorted=True),
SearchColumn("category", title=_("Category"), data_type=str, visible=False),
SearchColumn("branch_name", title=_("Branch"), data_type=str, visible=False),
SearchColumn("description", title=_("Description"), data_type=str, expand=True),
SearchColumn("manufacturer", title=_("Manufacturer"), data_type=str, visible=False),
SearchColumn("medic_name", title=_("Medic"), data_type=str),
SearchColumn("crm_number", title=_("CRM"), data_type=str),
SearchColumn("partner", title=_("Partner"), data_type=bool, visible=False, width=40),
SearchColumn("batch_number", title=_("Batch"), data_type=str, visible=False),
SearchColumn("batch_date", title=_("Batch Date"), data_type=datetime.date, visible=False),
SearchColumn("quantity", title=_("Qty"), data_type=decimal.Decimal, format_func=format_quantity),
SearchColumn("total", title=_("Total"), data_type=currency),
]
return columns
def on_sale_details_button__clicked(self, widget):
item = self.results.get_selected()
sale_view = self.store.find(SaleView, id=item.sale_id).one()
run_dialog(SaleDetailsDialog, self, self.store, sale_view)
示例4: search_for_date
# 需要导入模块: from stoqlib.gui.search.searchfilters import DateSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.DateSearchFilter import select [as 别名]
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()
示例5: FinancialReportDialog
# 需要导入模块: from stoqlib.gui.search.searchfilters import DateSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.DateSearchFilter import select [as 别名]
class FinancialReportDialog(BasicDialog):
title = _("Financial Report Dialog")
def __init__(self, store):
self.store = store
self.date_filter = DateSearchFilter(_("Year:"))
self.date_filter.clear_options()
self._populate_date_filter(self.date_filter)
self.date_filter.select()
self.date_filter.set_use_date_entries(False)
BasicDialog.__init__(self, title=self.title)
self.main_label.set_justify(gtk.JUSTIFY_CENTER)
self.ok_button.set_label(_("Generate"))
self.add(self.date_filter)
self.date_filter.show()
def confirm(self):
start = self.date_filter.get_start_date()
if start is None:
warning(_("There are no transactions yet"))
return
f = FinancialIntervalReport(self.store, start.year)
if not f.run():
return
temporary = tempfile.NamedTemporaryFile(
# Translators: This will be part of a filename
prefix=_("stoq-yearly-report"),
suffix=".xls",
delete=False,
)
f.write(temporary)
sse = SpreadSheetExporter()
sse.export_temporary(temporary)
self.close()
self.temporary = temporary
#
# Private
#
def _populate_date_filter(self, date_filter):
transaction = self.store.find(AccountTransaction).order_by(AccountTransaction.date).first()
if transaction is None:
return
for i in range(transaction.date.year, localtoday().year + 1):
year = datetime.datetime(i, 1, 1)
date_filter.add_option_fixed_interval(_("Year %d") % (i,), year, year.replace(month=12, day=31), position=0)
def _date_filter_query(self, search_spec, column):
executer = QueryExecuter(self.store)
executer.set_filter_columns(self.date_filter, [column])
executer.set_search_spec(search_spec)
return executer.search([self.date_filter.get_state()])
示例6: search_for_date
# 需要导入模块: from stoqlib.gui.search.searchfilters import DateSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.DateSearchFilter import select [as 别名]
def search_for_date(self, date):
self.main_filter.select(None)
dfilter = DateSearchFilter(_("Paid or due date"))
dfilter.set_removable()
dfilter.select(data=DateSearchFilter.Type.USER_DAY)
self.add_filter(dfilter, columns=["paid_date", "due_date"])
dfilter.start_date.set_date(date)
self.refresh()
示例7: search_for_date
# 需要导入模块: from stoqlib.gui.search.searchfilters import DateSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.DateSearchFilter import select [as 别名]
def search_for_date(self, date):
self.main_filter.combo.select(self._not_delivered_filter_item)
dfilter = DateSearchFilter(_("Estimated finish"))
dfilter.set_removable()
dfilter.select(data=DateSearchFilter.Type.USER_DAY)
self.add_filter(dfilter, columns=["estimated_finish"])
dfilter.start_date.set_date(date)
self.refresh()
示例8: create_filters
# 需要导入模块: from stoqlib.gui.search.searchfilters import DateSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.DateSearchFilter import select [as 别名]
def create_filters(self):
# Extra filters (that are not columns)
self.search.add_filter_option(SellableCategory.description, title=_(u"Product category"), data_type=str)
self.search.add_filter_option(Sellable.description, title=_(u"Product"), data_type=str)
# Date
date_filter = DateSearchFilter(_("Date:"))
date_filter.select(Today)
self.add_filter(date_filter, columns=[Sale.confirm_date])
示例9: create_filters
# 需要导入模块: from stoqlib.gui.search.searchfilters import DateSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.DateSearchFilter import select [as 别名]
def create_filters(self):
# Date
date_filter = DateSearchFilter(_('Date:'))
date_filter.select(Today)
columns = [ProductHistory.sold_date,
ProductHistory.received_date,
ProductHistory.production_date,
ProductHistory.decreased_date]
self.add_filter(date_filter, columns=columns)
self.date_filter = date_filter
示例10: create_filters
# 需要导入模块: from stoqlib.gui.search.searchfilters import DateSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.DateSearchFilter import select [as 别名]
def create_filters(self):
self.set_text_field_columns(["description", "identifier_str"])
self.search.set_query(self.executer_query)
# Date
date_filter = DateSearchFilter(_("Date:"))
date_filter.select(0)
columns = [Payment.due_date, Payment.open_date, Payment.paid_date]
self.add_filter(date_filter, columns=columns)
self.date_filter = date_filter
示例11: PaymentFlowHistoryDialog
# 需要导入模块: from stoqlib.gui.search.searchfilters import DateSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.DateSearchFilter import select [as 别名]
class PaymentFlowHistoryDialog(BasicDialog):
title = _(u'Payment Flow History Dialog')
desc = _("Select a date or a range to be visualised in the report:")
size = (-1, -1)
model_type = PaymentFlowDay
def __init__(self, store):
"""A dialog to print the PaymentFlowHistoryReport report.
:param store: a store
"""
self.store = store
BasicDialog.__init__(self, header_text='<b>%s</b>' % self.desc,
title=self.title)
self._setup_widgets()
#
# BasicDialog
#
def confirm(self):
state = self._date_filter.get_state()
from stoqlib.database.queryexecuter import DateQueryState
if isinstance(state, DateQueryState):
start, end = state.date, state.date
else:
start, end = state.start, state.end
results = PaymentFlowDay.get_flow_history(self.store, start, end)
if not results:
info(_('No payment history found.'))
return False
print_report(PaymentFlowHistoryReport, payment_histories=results)
return True
#
# Private
#
def _setup_widgets(self):
self.ok_button.set_label(gtk.STOCK_PRINT)
self._date_filter = DateSearchFilter(_(u'Date:'))
# FIXME: add a remove_option method in DateSearchFilter.
self._date_filter.clear_options()
self._date_filter.add_custom_options()
for option in [Today, Yesterday, LastWeek, LastMonth]:
self._date_filter.add_option(option)
self._date_filter.select(position=0)
self.vbox.pack_start(self._date_filter, False, False)
self._date_filter.show_all()
示例12: create_filters
# 需要导入模块: from stoqlib.gui.search.searchfilters import DateSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.DateSearchFilter import select [as 别名]
def create_filters(self):
self.set_text_field_columns(['description'])
self.executer.set_query(self.executer_query)
# Date
date_filter = DateSearchFilter(_('Date:'))
date_filter.select(0)
columns = [Payment.due_date,
Payment.open_date,
Payment.paid_date]
self.add_filter(date_filter, columns=columns)
self.date_filter = date_filter
示例13: add_filter_by_column
# 需要导入模块: from stoqlib.gui.search.searchfilters import DateSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.DateSearchFilter import select [as 别名]
def add_filter_by_column(self, column):
"""Add a filter accordingly to the column specification
:param column: a SearchColumn instance
"""
title = column.get_search_label()
if column.data_type is not bool:
title += ':'
if column.data_type == datetime.date:
filter = DateSearchFilter(title)
if column.valid_values:
filter.clear_options()
filter.add_custom_options()
for opt in column.valid_values:
filter.add_option(opt)
filter.select(column.valid_values[0])
elif (column.data_type == decimal.Decimal or
column.data_type == int or
column.data_type == currency):
filter = NumberSearchFilter(title)
if column.data_type != int:
filter.set_digits(2)
elif column.data_type == str:
if column.valid_values:
filter = ComboSearchFilter(title, column.valid_values)
else:
filter = StringSearchFilter(title)
filter.enable_advanced()
elif column.data_type == bool:
filter = BoolSearchFilter(title)
else:
raise NotImplementedError(title, column.data_type)
filter.set_removable()
attr = column.search_attribute or column.attribute
self.add_filter(filter, columns=[attr],
callback=column.search_func,
use_having=column.use_having)
if column.data_type is not bool:
label = filter.get_title_label()
label.set_alignment(1.0, 0.5)
self.label_group.add_widget(label)
combo = filter.get_mode_combo()
if combo:
self.combo_group.add_widget(combo)
return filter
示例14: DateRangeDialog
# 需要导入模块: from stoqlib.gui.search.searchfilters import DateSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.DateSearchFilter import select [as 别名]
class DateRangeDialog(BasicDialog):
"""A simple dialog for selecting a date range
When confirmed, a :class:`date_range` object will be returned
containig the information about the date range selected
"""
title = _(u'Select a date range')
size = (-1, -1)
def __init__(self, title=None, header_text=None):
title = title or self.title
header_text = '<b>%s</b>' % header_text if header_text else ''
BasicDialog.__init__(self, title=title, header_text=header_text)
self._setup_widgets()
#
# BasicDialog
#
def confirm(self):
BasicDialog.confirm(self)
state = self.date_filter.get_state()
if isinstance(state, DateQueryState):
start, end = state.date, state.date
else:
start, end = state.start, state.end
self.retval = date_range(start=start, end=end)
#
# Private
#
def _setup_widgets(self):
self.date_filter = DateSearchFilter(_(u'Date:'))
# FIXME: add a remove_option method in DateSearchFilter.
self.date_filter.clear_options()
self.date_filter.add_custom_options()
for option in [Today, Yesterday, LastWeek, LastMonth]:
self.date_filter.add_option(option)
self.date_filter.select(position=0)
self.vbox.pack_start(self.date_filter, False, False)
self.date_filter.show_all()
示例15: create_filters
# 需要导入模块: from stoqlib.gui.search.searchfilters import DateSearchFilter [as 别名]
# 或者: from stoqlib.gui.search.searchfilters.DateSearchFilter import select [as 别名]
def create_filters(self):
self.set_text_field_columns(['description'])
# Date
date_filter = DateSearchFilter(_('Date:'))
date_filter.select(Today)
columns = [ProductHistory.sold_date,
ProductHistory.received_date,
ProductHistory.production_date,
ProductHistory.decreased_date]
self.add_filter(date_filter, columns=columns)
self.date_filter = date_filter
# Branch
self.branch_filter = self.create_branch_filter(_('In branch:'))
self.add_filter(self.branch_filter, columns=['branch'],
position=SearchFilterPosition.TOP)
# remove 'Any' option from branch_filter
self.branch_filter.combo.remove_text(0)