def create_filters(self): # Category categories = self.store.find(SellableCategory) items = stoq_api.for_combo(categories, attr='full_description') items.insert(0, (_('Any'), None)) category_filter = ComboSearchFilter(_('Category'), items) self.add_filter(category_filter, columns=[Sellable.category])
def create_filters(self): statuses = [(desc, i) for i, desc in ProductionOrder.statuses.items()] statuses.insert(0, (_(u'Any'), None)) self.status_filter = ComboSearchFilter(_('order status:'), statuses) self.status_filter.select(ProductionOrder.ORDER_PRODUCING) self.add_filter(self.status_filter, columns=['order_status'], position=SearchFilterPosition.TOP)
def create_filters(self): self.set_text_field_columns(['supplier_name', 'identifier_str', 'invoice_numbers']) 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 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: 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
def create_filters(self): items = [(_('Active'), True), (_('Inactive'), False)] items.insert(0, (_('Any'), None)) status_filter = ComboSearchFilter(_('Show transporters with status'), items) status_filter.select(None) self.add_filter(status_filter, SearchFilterPosition.TOP, ['is_active'])
def create_filters(self): self.search.set_query(self._query_executer) self.set_text_field_columns(['client_name', 'salesperson_name', 'identifier_str', 'token_code', 'token_name']) self.status_filter = ComboSearchFilter(_(u"Show orders"), self._get_status_values()) self.add_filter(self.status_filter, position=SearchFilterPosition.TOP, columns=['status'])
def create_filters(self): # status filter statuses = [(desc, i) for i, desc in Loan.statuses.items()] statuses.insert(0, (_(u'Any'), None)) status_filter = ComboSearchFilter(_(u'with status:'), statuses) status_filter.select(None) self.add_filter(status_filter, columns=['loan_status'], position=SearchFilterPosition.TOP)
def create_salesperson_filter(self, label=None): from stoqlib.domain.person import SalesPerson items = SalesPerson.get_active_items( self.store, api.get_current_branch(self.store)) items.insert(0, (_("Any"), None)) if not label: label = _('Salesperson:') return ComboSearchFilter(label, items)
def create_filters(self): self.search.set_query(self.executer_query) # Category categories = self.store.find(SellableCategory) items = stoq_api.for_combo(categories, attr='full_description') items.insert(0, (_('Any'), None)) category_filter = ComboSearchFilter(_('Category'), items) self.add_filter(category_filter, position=SearchFilterPosition.TOP) self.category_filter = category_filter
def create_filters(self): statuses = [(value, key) for key, value in Branch.statuses.items()] statuses.insert(0, (_('Any'), None)) status_filter = ComboSearchFilter(_('Show branches with status'), statuses) status_filter.select(None) executer = self.search.get_query_executer() executer.add_filter_query_callback(status_filter, self._get_status_query) self.search.add_filter(status_filter, SearchFilterPosition.TOP)
def create_filters(self): self.set_text_field_columns(['recipient_name', 'identifier_str']) self.main_filter = ComboSearchFilter(_('Show'), []) self.add_filter(self.main_filter, SearchFilterPosition.TOP, callback=self._get_main_query) self.create_branch_filter(column=[Invoice.branch_id]) self._update_filters()
def create_filters(self): self.search.set_query(self._query) self.set_text_field_columns([ 'description', 'code', 'barcode', 'category_description', 'manufacturer' ]) branches = Branch.get_active_branches(self.store) self.branch_filter = ComboSearchFilter( _('Show by:'), api.for_combo(branches, empty=_("All branches"))) self.branch_filter.select(api.get_current_branch(self.store)) self.add_filter(self.branch_filter, position=SearchFilterPosition.TOP)
def create_provider_filter(self, label=None): from stoqlib.domain.payment.card import CreditProvider providers = CreditProvider.get_card_providers(self.store).order_by( CreditProvider.short_name) items = [(p.short_name, p) for p in providers] items.insert(0, (_("Any"), None)) if not label: label = _('Provider:') provider_filter = ComboSearchFilter(label, items) return provider_filter
def create_sellable_filter(self, label=None): from stoqlib.domain.sellable import Sellable items = [(desc, status) for status, desc in Sellable.statuses.items()] items.insert(0, (_(u"Any"), None)) if label is None: label = _('With status:') sellable_filter = ComboSearchFilter(label, items) # Select status available by default sellable_filter.select(Sellable.STATUS_AVAILABLE) return sellable_filter
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 create_filters(self): # Disable string search right now, until we use a proper Viewable # for this application self.search.disable_search_entry() self.branch_filter = ComboSearchFilter(_('Show inventories at:'), self._get_branches_for_filter()) current = api.get_current_branch(self.store) self.branch_filter.select(current.id) self.add_filter(self.branch_filter, SearchFilterPosition.TOP, columns=["branch_id"])
def create_filters(self): self.set_text_field_columns(['description', 'identifier_str']) executer = self.search.get_query_executer() executer.add_query_callback(self._get_query) # Status items = [(v, k) for k, v in Till.statuses.items() if k != Till.STATUS_PENDING] items.insert(0, (_(u'Any'), None)) status_filter = ComboSearchFilter(_(u'Show entries of type'), items) status_filter.select(Till.STATUS_OPEN) self.add_filter(status_filter, position=SearchFilterPosition.TOP, columns=['status'])
def create_filters(self): self.set_text_field_columns([ 'tracking_code', 'transporter_name', 'recipient_name', 'identifier_str' ]) # Status statuses = [(desc, st) for st, desc in Delivery.statuses.items()] statuses.insert(0, (_('Any'), None)) self.status_filter = ComboSearchFilter(_('With status:'), statuses) self.status_filter.select(None) self.add_filter(self.status_filter, columns=['status'], position=SearchFilterPosition.TOP)
def create_payment_filter(self, label=None): from stoqlib.domain.payment.method import PaymentMethod methods = PaymentMethod.get_active_methods(self.store) items = [(_('Any'), None)] for method in methods: if method.method_name == 'multiple': continue items.append((method.description, method)) if not label: label = _('Method:') payment_filter = ComboSearchFilter(label, items) payment_filter.select(None) return payment_filter
def create_filters(self): self.set_text_field_columns(['client_name', 'salesperson_name', 'identifier_str', 'token_code', 'token_name']) status_filter = ComboSearchFilter(_('Show sales'), self._get_filter_options()) status_filter.combo.set_row_separator_func( lambda model, titer: model[titer][0] == 'sep') executer = self.search.get_query_executer() executer.add_filter_query_callback( status_filter, self._get_status_query) self.add_filter(status_filter, position=SearchFilterPosition.TOP) self.create_branch_filter(column=Sale.branch_id)
def create_filters(self): self.set_text_field_columns([ 'source_branch_name', 'destination_branch_name', 'identifier_str' ]) # Date self.date_filter = DateSearchFilter(_('Date:')) self.add_filter(self.date_filter, columns=['open_date', 'finish_date']) # Status self.status_filter = ComboSearchFilter(_('With status:'), self._get_status_options()) self.status_filter.select('pending') executer = self.search.get_query_executer() executer.add_filter_query_callback(self.status_filter, self._get_status_query) self.add_filter(self.status_filter, position=SearchFilterPosition.TOP)
def create_filters(self): self.set_text_field_columns([ 'sellable', 'description', 'client_name', 'identifier_str', 'sale_identifier_str' ]) 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.add_filter(self.main_filter, SearchFilterPosition.TOP, callback=self._get_main_query) self.create_branch_filter( column=[WorkOrder.branch_id, WorkOrder.current_branch_id]) self._update_filters()
def create_filters(self): statuses = [(v, k) for k, v in Client.statuses.items()] statuses.insert(0, (_('Any'), None)) status_filter = ComboSearchFilter(_('Show clients with status'), statuses) status_filter.select(None) self.add_filter(status_filter, SearchFilterPosition.TOP, ['status']) if self._birth_date: birthday_filter = self.search.add_filter_by_attribute( 'birth_date', _('Birthday'), datetime.date, callback=self.birthday_search) # FIXME: The fifth position is a search by day. This is done # elsewhere too but we should not hardcode it. Try to # find a better solution in the future and fix everything birthday_filter.mode.select_item_by_position(5) birthday_filter.start_date.set_date(self._birth_date) self.search.refresh()
def create_branch_filter(self, label=None, column=None): """Returns a new branch filter. :param label: The label to be used for the filter :param column: When provided, besides creating the filter, we will also add it to the interface, filtering by the informed column. """ items = api.get_branches_for_filter(self.store, use_id=True) if not label: label = _('Branch:') if column and not isinstance(column, list): column = [column] branch_filter = ComboSearchFilter(label, items) current = api.get_current_branch(self.store) branch_filter.select(current.id) if column: self.add_filter(branch_filter, columns=column, position=SearchFilterPosition.TOP) return branch_filter
def create_filters(self): items = [(value, key) for key, value in Sale.statuses.items()] items.insert(0, (_('Any'), None)) status_filter = ComboSearchFilter(_('Show sales with status'), items) self.add_filter(status_filter, columns=[SaleView.status])
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 create_filters(self): status_filter = ComboSearchFilter(_('Show employees with status'), self._get_status_values()) self.add_filter(status_filter, SearchFilterPosition.TOP, ['status'])
def create_filters(self): items = [(v, k) for k, v in fiscal_book_entries.items()] self.entry_type = ComboSearchFilter(_('Show entries of type'), items) self.add_filter(self.entry_type, callback=self._get_entry_type_query, position=SearchFilterPosition.TOP)