Example #1
0
 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()
Example #2
0
    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
Example #3
0
 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()
Example #4
0
 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()