Beispiel #1
0
    def testHasInvoiceNumber(self):
        sale = self.create_sale()
        for i in range(10):
            self._add_product(sale, tax=18, price=50 + i)

        sale.order()
        self._add_payments(sale)
        sale.confirm()
        sale.client = self.create_client()
        address = self.create_address()
        address.person = sale.client.person

        layout = self.store.find(InvoiceLayout).one()
        invoice = SaleInvoice(sale, layout)
        self.assertFalse(invoice.has_invoice_number())

        field = self.store.find(InvoiceField,
                                field_name=u'INVOICE_NUMBER').one()
        if field is None:
            field = InvoiceField(x=0,
                                 y=0,
                                 width=6,
                                 height=1,
                                 layout=layout,
                                 field_name=u'INVOICE_NUMBER',
                                 store=self.store)
        else:
            field.layout = layout

        new_invoice = SaleInvoice(sale, layout)
        self.assertTrue(new_invoice.has_invoice_number())
Beispiel #2
0
    def test_has_invoice_number(self):
        sale = self.create_sale()
        for i in range(10):
            self._add_product(sale, tax=18, price=50 + i)

        sale.order()
        self._add_payments(sale)
        sale.confirm()
        sale.client = self.create_client()
        address = self.create_address()
        address.person = sale.client.person

        layout = self.store.find(InvoiceLayout).one()
        invoice = SaleInvoice(sale, layout)
        self.assertFalse(invoice.has_invoice_number())

        field = self.store.find(InvoiceField, field_name=u'INVOICE_NUMBER').one()
        if field is None:
            field = InvoiceField(x=0, y=0, width=6, height=1, layout=layout,
                                 field_name=u'INVOICE_NUMBER',
                                 store=self.store)
        else:
            field.layout = layout

        new_invoice = SaleInvoice(sale, layout)
        self.assertTrue(new_invoice.has_invoice_number())
Beispiel #3
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.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()
Beispiel #4
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()