本文整理汇总了Python中stoqlib.gui.search.searchslave.SearchSlave.save_columns方法的典型用法代码示例。如果您正苦于以下问题:Python SearchSlave.save_columns方法的具体用法?Python SearchSlave.save_columns怎么用?Python SearchSlave.save_columns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.gui.search.searchslave.SearchSlave
的用法示例。
在下文中一共展示了SearchSlave.save_columns方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SearchDialog
# 需要导入模块: from stoqlib.gui.search.searchslave import SearchSlave [as 别名]
# 或者: from stoqlib.gui.search.searchslave.SearchSlave import save_columns [as 别名]
#.........这里部分代码省略.........
button = gtk.Button(label=label)
if image:
image_widget = gtk.Image()
image_widget.set_from_file(
environ.find_resource('pixmaps', image))
image_widget.show()
button.set_image(image_widget)
elif stock:
button_set_image_with_label(button, stock, label)
self.action_area.set_layout(gtk.BUTTONBOX_START)
self.action_area.pack_start(button, False, False, 6)
return button
def set_details_button_sensitive(self, value):
self._details_slave.details_button.set_sensitive(value)
def set_print_button_sensitive(self, value):
self._details_slave.print_button.set_sensitive(value)
def get_selection(self):
mode = self.results.get_selection_mode()
if mode == gtk.SELECTION_BROWSE:
return self.results.get_selected()
return self.results.get_selected_rows()
def confirm(self, retval=None):
"""Confirms the dialog
:param retval: optional parameter which will be selected when the
dialog is closed
"""
if retval is None:
retval = self.get_selection()
self.retval = retval
self.search.save_columns()
# FIXME: This should chain up so the "confirm" signal gets emitted
self.close()
def cancel(self, *args):
self.retval = []
self.search.save_columns()
# FIXME: This should chain up so the "cancel" signal gets emitted
self.close()
# FIXME: -> remove/use
# TODO: Check if we can remove
def set_searchbar_label(self, label):
search_filter = self.search.get_primary_filter()
search_filter.set_label(label)
def set_searchbar_search_string(self, string):
if string == self.get_searchbar_search_string():
return
search_filter = self.search.get_primary_filter()
search_filter.entry.set_text(string)
def get_searchbar_search_string(self):
search_filter = self.search.get_primary_filter()
return search_filter.get_state().text
def set_text_field_columns(self, columns):
"""See :class:`SearchSlave.set_text_field_columns`
"""
self.search.set_text_field_columns(columns)
def disable_search_entry(self):
示例2: PurchaseSelectionStep
# 需要导入模块: from stoqlib.gui.search.searchslave import SearchSlave [as 别名]
# 或者: from stoqlib.gui.search.searchslave.SearchSlave import save_columns [as 别名]
class PurchaseSelectionStep(BaseWizardStep):
gladefile = 'PurchaseSelectionStep'
def __init__(self, wizard, store):
self._next_step = None
BaseWizardStep.__init__(self, store, wizard)
self.setup_slaves()
def _create_search(self):
self.search = SearchSlave(self._get_columns(),
restore_name=self.__class__.__name__,
store=self.store,
search_spec=PurchaseOrderView)
self.search.enable_advanced_search()
self.attach_slave('searchbar_holder', self.search)
executer = self.search.get_query_executer()
executer.add_query_callback(self.get_extra_query)
self._create_filters()
self.search.result_view.set_selection_mode(gtk.SELECTION_MULTIPLE)
self.search.result_view.connect('selection-changed',
self._on_results__selection_changed)
self.search.result_view.connect('row-activated',
self._on_results__row_activated)
self.search.focus_search_entry()
def _create_filters(self):
self.search.set_text_field_columns(['supplier_name', 'identifier_str'])
def get_extra_query(self, states):
query = PurchaseOrderView.status == PurchaseOrder.ORDER_CONFIRMED
# Dont let the user receive purchases from other branches when working
# in synchronized mode
if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
branch = api.get_current_branch(self.store)
query = And(query,
PurchaseOrderView.branch_id == branch.id)
return query
def _get_columns(self):
return [IdentifierColumn('identifier', sorted=True),
SearchColumn('open_date', title=_('Date Started'),
data_type=datetime.date, width=100),
SearchColumn('expected_receival_date', data_type=datetime.date,
title=_('Expected Receival'), visible=False),
SearchColumn('supplier_name', title=_('Supplier'),
data_type=str, searchable=True, width=130,
expand=True),
SearchColumn('ordered_quantity', title=_('Qty Ordered'),
data_type=Decimal, width=110,
format_func=format_quantity),
SearchColumn('received_quantity', title=_('Qty Received'),
data_type=Decimal, width=145,
format_func=format_quantity),
SearchColumn('total', title=_('Order Total'),
data_type=currency, width=120)]
def _update_view(self):
selected_rows = self.search.result_view.get_selected_rows()
can_continue = len(set((v.supplier_id, v.branch_id) for v in selected_rows)) == 1
self.wizard.refresh_next(can_continue)
self.details_button.set_sensitive(len(selected_rows) == 1)
#
# WizardStep hooks
#
def post_init(self):
self._update_view()
self.force_validation()
def next_step(self):
self.search.save_columns()
selected_rows = self.search.result_view.get_selected_rows()
return ReceivingOrderItemStep(self.store, self.wizard, self,
selected_rows)
def has_previous_step(self):
return False
def setup_slaves(self):
self._create_search()
#
# Kiwi callbacks
#
def _on_results__selection_changed(self, results, purchase_order_view):
self.force_validation()
self._update_view()
def _on_results__row_activated(self, results, purchase_order_view):
run_dialog(PurchaseDetailsDialog, self.wizard, self.store,
model=purchase_order_view.purchase)
def on_details_button__clicked(self, *args):
selected = self.search.results.get_selected_rows()[0]
if not selected:
raise ValueError('You should have one order selected '
#.........这里部分代码省略.........
示例3: QuoteGroupSelectionStep
# 需要导入模块: from stoqlib.gui.search.searchslave import SearchSlave [as 别名]
# 或者: from stoqlib.gui.search.searchslave.SearchSlave import save_columns [as 别名]
class QuoteGroupSelectionStep(BaseWizardStep):
gladefile = 'QuoteGroupSelectionStep'
def __init__(self, wizard, store):
self._next_step = None
BaseWizardStep.__init__(self, store, wizard)
self._setup_slaves()
def _setup_slaves(self):
self.search = SearchSlave(self._get_columns(),
restore_name=self.__class__.__name__,
search_spec=QuotationView,
store=self.store)
self.attach_slave('search_group_holder', self.search)
self.search.set_text_field_columns(['supplier_name', 'identifier_str'])
filter = self.search.get_primary_filter()
filter.set_label(_(u'Supplier:'))
self.search.focus_search_entry()
self.search.results.connect('selection-changed',
self._on_searchlist__selection_changed)
self.search.results.connect('row-activated',
self._on_searchlist__row_activated)
date_filter = DateSearchFilter(_('Date:'))
self.search.add_filter(date_filter, columns=['open_date', 'deadline'])
self.edit_button.set_sensitive(False)
self.remove_button.set_sensitive(False)
def _get_columns(self):
return [IdentifierColumn('identifier', title=_("Quote #"), sorted=True),
IdentifierColumn('group_identifier', title=_('Group #')),
Column('supplier_name', title=_('Supplier'), data_type=str,
width=300),
Column('open_date', title=_('Open date'),
data_type=datetime.date),
Column('deadline', title=_('Deadline'),
data_type=datetime.date)]
def _can_purchase(self, item):
return item.cost > currency(0) and item.quantity > Decimal(0)
def _can_order(self, quotation):
if quotation is None:
return False
for item in quotation.purchase.get_items():
if not self._can_purchase(item):
return False
return True
def _update_view(self):
selected = self.search.results.get_selected()
has_selected = selected is not None
self.edit_button.set_sensitive(has_selected)
self.remove_button.set_sensitive(has_selected)
self.wizard.refresh_next(self._can_order(selected))
def _run_quote_editor(self):
store = api.new_store()
selected = store.fetch(self.search.results.get_selected().purchase)
retval = run_dialog(QuoteFillingDialog, self.wizard, selected, store)
store.confirm(retval)
store.close()
self._update_view()
def _remove_quote(self):
q = self.search.results.get_selected().quotation
msg = _('Are you sure you want to remove "%s" ?') % q.get_description()
if not yesno(msg, gtk.RESPONSE_NO,
_("Remove quote"), _("Don't remove")):
return
store = api.new_store()
group = store.fetch(q.group)
quote = store.fetch(q)
group.remove_item(quote)
# there is no reason to keep the group if there's no more quotes
if group.get_items().count() == 0:
store.remove(group)
store.confirm(True)
store.close()
self.search.refresh()
#
# WizardStep hooks
#
def next_step(self):
self.search.save_columns()
selected = self.search.results.get_selected()
if selected is None:
return
return QuoteGroupItemsSelectionStep(self.wizard, self.store,
selected.group, self)
#
# Callbacks
#.........这里部分代码省略.........
示例4: SearchDialog
# 需要导入模块: from stoqlib.gui.search.searchslave import SearchSlave [as 别名]
# 或者: from stoqlib.gui.search.searchslave.SearchSlave import save_columns [as 别名]
#.........这里部分代码省略.........
self.action_area.set_layout(gtk.BUTTONBOX_END)
self.action_area.pack_start(button, False, False, 6)
self.action_area.set_child_secondary(button, True)
return button
def add_csv_button(self, name, prefix):
self._csv_name = name
self._csv_prefix = prefix
self.csv_button = self.add_button(label=_("Export to spreadsheet..."))
self.csv_button.connect('clicked', self._on_export_csv_button__clicked)
self.csv_button.show()
self.csv_button.set_sensitive(False)
def set_details_button_sensitive(self, value):
self._details_slave.details_button.set_sensitive(value)
def set_print_button_sensitive(self, value):
self._details_slave.print_button.set_sensitive(value)
def get_selection(self):
mode = self.results.get_selection_mode()
if mode == gtk.SELECTION_BROWSE:
return self.results.get_selected()
return self.results.get_selected_rows()
def confirm(self, retval=None):
"""Confirms the dialog
:param retval: optional parameter which will be selected when the
dialog is closed
"""
if retval is None:
retval = self.get_selection()
self.retval = retval
self.search.save_columns()
# FIXME: This should chain up so the "confirm" signal gets emitted
self.close()
def cancel(self, *args):
self.retval = []
self.search.save_columns()
# FIXME: This should chain up so the "cancel" signal gets emitted
self.close()
def print_report(self):
print_report(self.report_class, self.results, list(self.results),
filters=self.search.get_search_filters())
# FIXME: This should be on BasePersonSearch
def birthday_search(self, state):
""" Returns a birthday query suitable for search filters.
This should be assigned on search_column when you want to filter for
birth day. e.g.:
SearchColumn('birth_date', search_column=self.birthday_search)
"""
if isinstance(state, DateQueryState):
if state.date:
return Individual.get_birthday_query(state.date)
elif isinstance(state, DateIntervalQueryState):
if state.start and state.end:
return Individual.get_birthday_query(state.start, state.end)
else:
raise AssertionError
# FIXME: -> remove/use
# TODO: Check if we can remove
示例5: ReceivingSelectionStep
# 需要导入模块: from stoqlib.gui.search.searchslave import SearchSlave [as 别名]
# 或者: from stoqlib.gui.search.searchslave.SearchSlave import save_columns [as 别名]
class ReceivingSelectionStep(BaseWizardStep):
gladefile = 'PurchaseSelectionStep'
def __init__(self, wizard, store):
self._next_step = None
BaseWizardStep.__init__(self, store, wizard)
self.setup_slaves()
def _create_search(self):
self.search = SearchSlave(self._get_columns(),
restore_name=self.__class__.__name__,
store=self.store,
search_spec=PurchaseReceivingView)
self.search.enable_advanced_search()
self.attach_slave('searchbar_holder', self.search)
executer = self.search.get_query_executer()
executer.add_query_callback(self.get_extra_query)
self._create_filters()
self.search.result_view.set_selection_mode(Gtk.SelectionMode.MULTIPLE)
self.search.result_view.connect('selection-changed',
self._on_results__selection_changed)
self.search.result_view.connect('row-activated',
self._on_results__row_activated)
self.search.focus_search_entry()
def _create_filters(self):
self.search.set_text_field_columns(['supplier_name', 'purchase_identifier'])
def get_extra_query(self, states):
query = And(Eq(PurchaseReceivingView.purchase_group, None),
Eq(PurchaseReceivingView.receiving_invoice, None))
# Dont let the user receive purchases from other branches when working
# in synchronized mode
if (api.sysparam.get_bool('SYNCHRONIZED_MODE') and not
api.can_see_all_branches()):
branch = api.get_current_branch(self.store)
query = And(query, PurchaseReceivingView.branch_id == branch.id)
return query
def _get_columns(self):
return [IdentifierColumn('identifier', _('Receiving #'), width=140),
IdentifierColumn('purchase_identifier', _('Purchase #'), width=110),
SearchColumn('packing_number', title=_('Packing Number'),
data_type=str, visible=False),
SearchColumn('receival_date', _('Receival date'), expand=True,
data_type=datetime.date, sorted=True, width=110),
SearchColumn('supplier_name', _('Supplier'), data_type=str,
expand=True),
SearchColumn('responsible_name', _('Responsible'),
data_type=str, visible=False, expand=True),
SearchColumn('purchase_responsible_name', _('Purchaser'),
data_type=str, visible=False, expand=True),
SearchColumn('invoice_number', _('Invoice #'), data_type=int,
width=80),
Column('subtotal', title=_('Products total'),
data_type=currency, width=150)]
def _update_view(self):
selected_rows = self.search.result_view.get_selected_rows()
can_continue = len(set((v.supplier_id, v.branch_id) for v in selected_rows)) == 1
self.wizard.refresh_next(can_continue)
self.details_button.set_sensitive(len(selected_rows) == 1)
#
# WizardStep hooks
#
def post_init(self):
self._update_view()
self.force_validation()
def next_step(self):
self.search.save_columns()
selected_rows = self.search.result_view.get_selected_rows()
return ProductsCostCheckStep(self.wizard, self, self.store, selected_rows)
def has_previous_step(self):
return False
def setup_slaves(self):
self._create_search()
#
# Kiwi callbacks
#
def _on_results__selection_changed(self, results, purchase_order_view):
self.force_validation()
self._update_view()
def _on_results__row_activated(self, results, receiving_order_view):
run_dialog(ReceivingOrderDetailsDialog, self.wizard, self.store,
model=receiving_order_view.order)
def on_details_button__clicked(self, *args):
selected = self.search.results.get_selected_rows()[0]
if not selected:
raise ValueError('You should have one order selected '
#.........这里部分代码省略.........
示例6: PurchaseSelectionStep
# 需要导入模块: from stoqlib.gui.search.searchslave import SearchSlave [as 别名]
# 或者: from stoqlib.gui.search.searchslave.SearchSlave import save_columns [as 别名]
class PurchaseSelectionStep(BaseWizardStep):
gladefile = 'PurchaseSelectionStep'
def __init__(self, wizard, store):
self._next_step = None
BaseWizardStep.__init__(self, store, wizard)
self.setup_slaves()
def _refresh_next(self, validation_value):
has_selection = self.search.results.get_selected() is not None
self.wizard.refresh_next(has_selection)
def _create_search(self):
self.search = SearchSlave(self._get_columns(),
restore_name=self.__class__.__name__,
store=self.store,
search_spec=PurchaseOrderView)
self.search.enable_advanced_search()
self.attach_slave('searchbar_holder', self.search)
executer = self.search.get_query_executer()
executer.add_query_callback(self.get_extra_query)
self._create_filters()
self.search.results.connect('selection-changed',
self._on_results__selection_changed)
self.search.results.connect('row-activated',
self._on_results__row_activated)
self.search.focus_search_entry()
def _create_filters(self):
self.search.set_text_field_columns(['supplier_name', 'identifier_str'])
def get_extra_query(self, states):
query = PurchaseOrderView.status == PurchaseOrder.ORDER_CONFIRMED
# Dont let the user receive purchases from other branches when working
# in synchronized mode
if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
branch = api.get_current_branch(self.store)
query = And(query,
PurchaseOrderView.branch_id == branch.id)
return query
def _get_columns(self):
return [IdentifierColumn('identifier', sorted=True),
SearchColumn('open_date', title=_('Date Started'),
data_type=datetime.date, width=100),
SearchColumn('expected_receival_date', data_type=datetime.date,
title=_('Expected Receival'), visible=False),
SearchColumn('supplier_name', title=_('Supplier'),
data_type=str, searchable=True, width=130,
expand=True),
SearchColumn('ordered_quantity', title=_('Qty Ordered'),
data_type=Decimal, width=110,
format_func=format_quantity),
SearchColumn('received_quantity', title=_('Qty Received'),
data_type=Decimal, width=145,
format_func=format_quantity),
SearchColumn('total', title=_('Order Total'),
data_type=currency, width=120)]
def _update_view(self):
has_selection = self.search.results.get_selected() is not None
self.details_button.set_sensitive(has_selection)
#
# WizardStep hooks
#
def post_init(self):
self._update_view()
self.register_validate_function(self._refresh_next)
self.force_validation()
def next_step(self):
self.search.save_columns()
selected = self.search.results.get_selected()
purchase = selected.purchase
# We cannot create the model in the wizard since we haven't
# selected a PurchaseOrder yet which ReceivingOrder depends on
# Create the order here since this is the first place where we
# actually have a purchase selected
if not self.wizard.model:
self.wizard.model = self.model = ReceivingOrder(
responsible=api.get_current_user(self.store),
supplier=purchase.supplier, invoice_number=None,
branch=purchase.branch, purchase=purchase,
store=self.store)
# Remove all the items added previously, used if we hit back
# at any point in the wizard.
if self.model.purchase != purchase:
self.model.remove_items()
# This forces ReceivingOrderProductStep to create a new model
self._next_step = None
if selected:
self.model.purchase = purchase
self.model.branch = purchase.branch
self.model.supplier = purchase.supplier
#.........这里部分代码省略.........