[POS-commit] r1896 - in stoq/trunk/stoq: examples lib

Henrique Romano henrique at async.com.br
Thu Dec 15 10:21:41 BRST 2005


Author: henrique
Date: Thu Dec 15 10:21:40 2005
New Revision: 1896

Added:
   stoq/trunk/stoq/examples/drivers.py
Modified:
   stoq/trunk/stoq/examples/createall.py
   stoq/trunk/stoq/lib/drivers.py
Log:
Fix for bug #2345: Impeding Sale confirmation if there is no fiscalprinter 
configured for the current station.
r=jdahlin




Modified: stoq/trunk/stoq/examples/createall.py
==============================================================================
--- stoq/trunk/stoq/examples/createall.py	(original)
+++ stoq/trunk/stoq/examples/createall.py	Thu Dec 15 10:21:40 2005
@@ -36,6 +36,7 @@
 from stoq.examples.sale import create_sales
 from stoq.examples.payment import create_payments
 from stoq.examples.purchase import create_purchases
+from stoq.examples.drivers import create_printer_setting
 
 VERBOSE = '-v' in sys.argv
 
@@ -48,6 +49,7 @@
     create_payments()
     create_sales()
     create_purchases()
+    create_printer_setting()
     print_msg('done.')
 
 if __name__ == "__main__":

Added: stoq/trunk/stoq/examples/drivers.py
==============================================================================
--- (empty file)
+++ stoq/trunk/stoq/examples/drivers.py	Thu Dec 15 10:21:40 2005
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+# -*- Mode: Python; coding: iso-8859-1 -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+##
+## Copyright (C) 2005 Async Open Source <http://www.async.com.br>
+## All rights reserved
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+## USA.
+##
+## Author(s): Henrique Romano <henrique at async.com.br>
+##
+"""
+stoq/examples/drivers.py:
+
+    Create a PrinterSetting object that use a VirtualPrinter by default.
+"""
+
+import socket
+
+from stoq.lib.runtime import new_transaction, print_msg
+from stoq.domain.drivers import PrinterSettings
+
+def create_printer_setting():
+    print_msg("Creating default printer settings", break_line=False)
+    conn = new_transaction()
+    printer = PrinterSettings(connection=conn)
+    printer.host = socket.gethostname()
+    printer.device = PrinterSettings.DEVICE_SERIAL1
+    printer.brand = 'virtual'
+    printer.model = 'Simple'
+    conn.commit()
+    print_msg("done.")
+
+if __name__ == "__main__":
+    create_printer_setting()

Modified: stoq/trunk/stoq/lib/drivers.py
==============================================================================
--- stoq/trunk/stoq/lib/drivers.py	(original)
+++ stoq/trunk/stoq/lib/drivers.py	Thu Dec 15 10:21:40 2005
@@ -35,7 +35,7 @@
 from sqlobject.sqlbuilder import OR
 from stoqlib.exceptions import DatabaseInconsistency
 from stoqlib.exceptions import _warn
-from kiwi.ui.dialogs import warning
+from kiwi.ui.dialogs import warning, error
 from stoqdrivers.devices.printers.fiscal import FiscalPrinter
 from stoqdrivers.constants import (UNIT_EMPTY, TAX_NONE, MONEY_PM,
                                    CHEQUE_PM)
@@ -80,8 +80,9 @@
         _printer = FiscalPrinter(brand=setting.brand, model=setting.model,
                                  device=setting.get_device_name())
     else:
-        _warn("There is no fiscalprinter configured for this station (%s)"
-              % socket.gethostname())
+        error(_("There is no printer configured"),
+              _("There is no printer configured this station (\"%s\")"
+                % socket.gethostname()))
     return _printer
 
 def _cancel(printer):
@@ -96,7 +97,7 @@
 def _emit_reading(conn, cmd):
     printer = _get_fiscalprinter(conn)
     if not printer:
-        return
+        return False
     try:
         getattr(printer, cmd)()
     except CouponOpenError:
@@ -189,3 +190,4 @@
     except DriverError, details:
         warning(_("Isn't possible close the coupon"), str(details))
         return False
+    return True


More information about the POS-commit mailing list