Ejemplo n.º 1
0
 def test_get_by_station(self):
     station = self.create_station()
     self.failIf(InvoicePrinter.get_by_station(station, self.store))
     InvoicePrinter(
         store=self.store, description=u"test invoice", layout=None, device_name=u"/dev/lp0", station=station
     )
     printer = InvoicePrinter.get_by_station(station, self.store)
     self.failUnless(printer)
     self.assertEqual(printer.station, station)
Ejemplo n.º 2
0
 def test_get_by_station(self):
     station = self.create_station()
     self.failIf(InvoicePrinter.get_by_station(station, self.store))
     InvoicePrinter(store=self.store,
                    description=u'test invoice',
                    layout=None,
                    device_name=u'/dev/lp0',
                    station=station)
     printer = InvoicePrinter.get_by_station(station, self.store)
     self.failUnless(printer)
     self.assertEqual(printer.station, station)
Ejemplo n.º 3
0
    def test_print_invoice(self, info, print_sale_invoice, run_dialog,
                           new_store):
        new_store.return_value = self.store

        app = self.create_app(SalesApp, u'sales')
        results = app.results
        results.select(results[0])

        self.activate(app.SalesPrintInvoice)
        info.assert_called_once_with(
            u"There are no invoice printer configured "
            u"for this station")

        layout = InvoiceLayout(description=u'layout',
                               width=10,
                               height=20,
                               store=self.store)
        printer = InvoicePrinter(store=self.store,
                                 description=u'test invoice',
                                 layout=layout,
                                 device_name=u'/dev/lp0',
                                 station=api.get_current_station(self.store))
        self.activate(app.SalesPrintInvoice)
        self.assertEquals(print_sale_invoice.call_count, 1)
        args, kwargs = print_sale_invoice.call_args
        invoice, called_printer = args
        self.assertTrue(isinstance(invoice, SaleInvoice))
        self.assertEquals(printer, called_printer)

        results[0].sale.invoice.invoice_number = None
        InvoiceField(layout=layout,
                     x=0,
                     y=0,
                     width=1,
                     height=1,
                     field_name=u'INVOICE_NUMBER',
                     store=self.store)
        with mock.patch.object(self.store, 'commit'):
            with mock.patch.object(self.store, 'close'):
                self.activate(app.SalesPrintInvoice)
                run_dialog.assert_called_once_with(SaleInvoicePrinterDialog,
                                                   self.store, results[0].sale,
                                                   printer)
Ejemplo n.º 4
0
Archivo: sales.py Proyecto: stoq/stoq
    def _print_invoice(self):
        sale_view = self.results.get_selected()
        assert sale_view
        sale = sale_view.sale
        station = api.get_current_station(self.store)
        printer = InvoicePrinter.get_by_station(station, self.store)
        if printer is None:
            info(_("There are no invoice printer configured for this station"))
            return
        assert printer.layout

        invoice = SaleInvoice(sale, printer.layout)
        if not invoice.has_invoice_number() or sale.invoice.invoice_number:
            print_sale_invoice(invoice, printer)
        else:
            store = api.new_store()
            retval = self.run_dialog(SaleInvoicePrinterDialog, store, store.fetch(sale), printer)
            store.confirm(retval)
            store.close()
Ejemplo n.º 5
0
    def _print_invoice(self):
        sale_view = self.results.get_selected()
        assert sale_view
        sale = sale_view.sale
        station = api.get_current_station(self.store)
        printer = InvoicePrinter.get_by_station(station, self.store)
        if printer is None:
            info(_("There are no invoice printer configured for this station"))
            return
        assert printer.layout

        invoice = SaleInvoice(sale, printer.layout)
        if not invoice.has_invoice_number() or sale.invoice_number:
            print_sale_invoice(invoice, printer)
        else:
            store = api.new_store()
            retval = self.run_dialog(SaleInvoicePrinterDialog, store,
                                     store.fetch(sale), printer)
            store.confirm(retval)
            store.close()
Ejemplo n.º 6
0
 def create_model(self, store):
     return InvoicePrinter(description=_(u'Untitled Printer'),
                           device_name=u'/dev/lp0',
                           station=get_current_station(store),
                           layout=None,
                           store=store)
Ejemplo n.º 7
0
 def create_invoice_printer(self):
     from stoqlib.domain.invoice import InvoicePrinter
     return InvoicePrinter(device_name=u'/dev/ttyS0',
                           description=u'Invoice Printer',
                           store=self.store)