From 6badffa8e47d0f9d4cc66ee3290f85df15c2816e Mon Sep 17 00:00:00 2001 From: georgeyk Date: Thu, 19 May 2011 14:16:16 -0300 Subject: [PATCH] Add more search columns/filters in LoanSearch. --- stoqlib/domain/views.py | 3 +++ stoqlib/gui/search/loansearch.py | 22 +++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/stoqlib/domain/views.py b/stoqlib/domain/views.py index d5df4ea727..44209fe903 100644 --- a/stoqlib/domain/views.py +++ b/stoqlib/domain/views.py @@ -767,6 +767,7 @@ class LoanView(Viewable): close_date=Loan.q.close_date, expire_date=Loan.q.expire_date, + removed_by=Loan.q.removed_by, branch_name=PersonBranch.q.name, responsible_name=PersonResponsible.q.name, client_name=PersonClient.q.name, @@ -801,6 +802,8 @@ class LoanItemView(Viewable): return_quantity=LoanItem.q.return_quantity, price=LoanItem.q.price, total=LoanItem.q.quantity * LoanItem.q.price, + sellable_id=Sellable.q.id, + code=Sellable.q.code, category_description=SellableCategory.q.description, unit_description=SellableUnit.q.description, description=BaseSellableInfo.q.description,) diff --git a/stoqlib/gui/search/loansearch.py b/stoqlib/gui/search/loansearch.py index ae6b43529d..0873c7883b 100644 --- a/stoqlib/gui/search/loansearch.py +++ b/stoqlib/gui/search/loansearch.py @@ -33,7 +33,7 @@ from kiwi.ui.search import ComboSearchFilter, DateSearchFilter from stoqlib.domain.loan import Loan -from stoqlib.domain.views import LoanItemView +from stoqlib.domain.views import LoanView, LoanItemView from stoqlib.gui.base.dialogs import run_dialog from stoqlib.gui.base.search import SearchDialog from stoqlib.gui.dialogs.loandetails import LoanDetailsDialog @@ -72,6 +72,10 @@ def get_columns(self): data_type=datetime.date, visible=False), SearchColumn('closed', title=_(u'Close Date'), data_type=datetime.date,), + SearchColumn('code', title=_(u'Code'), data_type=str, + visible=False), + SearchColumn('category_description', title=_(u'Category'), + data_type=str, visible=False), SearchColumn('description', title=_(u'Description'), data_type=str, expand=True), SearchColumn('quantity', title=_(u'Quantity'), @@ -88,7 +92,7 @@ def get_columns(self): class LoanSearch(SearchDialog): title = _(u"Loan Search") size = (750, 500) - search_table = Loan + search_table = LoanView selection_mode = gtk.SELECTION_MULTIPLE searchbar_result_strings = _(u"loan"), _(u"loans") search_by_date = True @@ -121,7 +125,7 @@ def _has_rows(self, results, obj): pass def create_filters(self): - self.set_text_field_columns([]) + self.set_text_field_columns(['client_name', 'removed_by']) self.set_searchbar_labels(_('matching:')) # Date @@ -138,24 +142,28 @@ def get_columns(self): data_type=unicode, expand=True), Column('client_name', _('Client'), data_type=unicode, width=120), + Column('removed_by', _('Removed By'), data_type=unicode, + width=120), ] # # Callbacks # - def on_row_activated(self, klist, item): + def on_row_activated(self, klist, item_view): + item = Loan.get(item_view.id, connection=self.conn) self._show_details(item) def on_print_button_clicked(self, button): orders = self.results.get_selected_rows() if len(orders) == 1: - print_report(LoanReceipt, orders[0] ) - pass + loan = Loan.get(orders[0].id, connection=self.conn) + print_report(LoanReceipt, loan) def on_details_button_clicked(self, button): orders = self.results.get_selected_rows() if len(orders) > 1: raise ValueError("You should have only one item selected at " "this point ") - self._show_details(orders[0]) + loan = Loan.get(orders[0].id, connection=self.conn) + self._show_details(loan)