[POS-commit] r5405 - in stoq/trunk/stoq/gui: pos
Johan Dahlin
jdahlin at async.com.br
Wed Nov 29 19:23:45 BRST 2006
Author: jdahlin
Date: Wed Nov 29 19:23:43 2006
New Revision: 5405
Modified:
stoq/trunk/stoq/gui/pos/pos.py
stoq/trunk/stoq/gui/till/till.py
Log:
#2973: Bloqueios devido ao não fechamento de caixa, stoq part
Modified: stoq/trunk/stoq/gui/pos/pos.py
==============================================================================
--- stoq/trunk/stoq/gui/pos/pos.py (original)
+++ stoq/trunk/stoq/gui/pos/pos.py Wed Nov 29 19:23:43 2006
@@ -36,7 +36,7 @@
from kiwi.ui.widgets.list import Column
from kiwi.python import Settable
from stoqdrivers.constants import UNIT_WEIGHT
-from stoqlib.exceptions import StoqlibError
+from stoqlib.exceptions import StoqlibError, TillError
from stoqlib.database.database import rollback_and_begin, finish_transaction
from stoqlib.database.runtime import new_transaction, get_current_user
from stoqlib.lib.message import warning, yesno
@@ -207,9 +207,17 @@
self.sellables.select(self.sellables[0])
def _update_widgets(self):
- has_till = Till.get_current(self.conn) is not None
- self.TillOpen.set_sensitive(not has_till and self.sale is None)
- self.TillClose.set_sensitive(has_till and self.sale is None)
+ try:
+ has_till = Till.get_current(self.conn) is not None
+ till_close = has_till
+ till_open = not has_till
+ except TillError:
+ has_till = False
+ till_close = True
+ till_open = False
+
+ self.TillOpen.set_sensitive(till_open and self.sale is None)
+ self.TillClose.set_sensitive(till_close and self.sale is None)
has_sellables = len(self.sellables) >= 1
self.set_sensitive((self.checkout_button, self.remove_item_button,
self.PrintOrder, self.NewDelivery,
@@ -335,9 +343,14 @@
self.sellables.update(item)
def _new_order(self):
- if not Till.get_current(self.conn):
- warning(_(u"You need open the till before start doing sales."))
- return
+ try:
+ till = Till.get_current(self.conn)
+ if not till:
+ warning(_(u"You need open the till before start doing sales."))
+ return
+ except TillError:
+ till = None
+
if not ISalesPerson(get_current_user(self.conn).person, None):
warning(_(u"You can't start a new sale, since you are not a "
"salesperson."))
Modified: stoq/trunk/stoq/gui/till/till.py
==============================================================================
--- stoq/trunk/stoq/gui/till/till.py (original)
+++ stoq/trunk/stoq/gui/till/till.py Wed Nov 29 19:23:43 2006
@@ -31,7 +31,7 @@
import gtk
from kiwi.datatypes import currency, converter
from kiwi.ui.widgets.list import Column
-from stoqlib.exceptions import StoqlibError
+from stoqlib.exceptions import StoqlibError, TillError
from stoqlib.database.database import rollback_and_begin, finish_transaction
from stoqlib.database.runtime import new_transaction, get_current_branch
from stoqlib.domain.sale import Sale, SaleView
@@ -102,24 +102,41 @@
self.confirm_order_button.set_sensitive(accept_confirm)
def _update_widgets(self):
- has_till = Till.get_current(self.conn) is not None
- self.TillClose.set_sensitive(has_till)
- self.TillOpen.set_sensitive(not has_till)
+ # Three different options;
+ #
+ # - Till is closed
+ # - Till is opened
+ # - Till was not closed the previous fiscal day
+ #
+
+ try:
+ till = Till.get_current(self.conn)
+ except TillError:
+ till = Till.get_last_opened(self.conn)
+ # We forgot to close the till the last opened day
+ close_till = True
+ open_till = False
+ has_till = False
+ else:
+ has_till = till is None
+ close_till = has_till
+ open_till = not has_till
+
+ self.TillClose.set_sensitive(close_till)
+ self.TillOpen.set_sensitive(open_till)
self.AddCash.set_sensitive(has_till)
self.RemoveCash.set_sensitive(has_till)
self.Treasury.set_sensitive(has_till)
- till = Till.get_current(self.conn)
if not till:
text = _(u"Till Closed")
self.sales.clear()
self.searchbar.clear()
else:
- opendate = till.opening_date
- datestr = opendate.strftime('%x')
- text = _(u"Till Opened on %s") % datestr
+ text = _(u"Till Opened on %s") % till.opening_date.strftime('%x')
+
self.till_status_label.set_text(text)
- self.app_vbox.set_sensitive(till is not None)
+ self.app_vbox.set_sensitive(open_till)
self._update_toolbar_buttons()
self._update_total()
More information about the POS-commit
mailing list