Skip to content

Commit

Permalink
Add more search columns/filters in LoanSearch.
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeyk committed May 19, 2011
1 parent 059c505 commit 6badffa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions stoqlib/domain/views.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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,)
Expand Down
22 changes: 15 additions & 7 deletions stoqlib/gui/search/loansearch.py
Expand Up @@ -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
Expand Down Expand Up @@ -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'),
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)

0 comments on commit 6badffa

Please sign in to comment.