コード例 #1
0
    def on_items_view_row_activated(self, treeview, path, column):
        self.logger.debug("on_items_view_row_activated")

        tree_iter = self.delivery_note_items_model.get_iter(path)
        item_type = self.delivery_note_items_model.get_value(
                tree_iter, self.ITEM_TYPE_COLUMN
                )

        dnote = self.selected_delivery_note
        self.logger.debug("item_type: %s", item_type)
        self.logger.debug("item_type: %s", ITEM_TYPES.inv[item_type])
        delivery_note_item = DeliveryNoteItem.select().where(
                (DeliveryNoteItem.delivery_note == dnote) and
                (DeliveryNoteItem.item_type == ITEM_TYPES.inv[item_type])
                ).get()

        column_id = column.get_sort_column_id()
        if column_id == self.REMOVE_ITEM_COLUMN:
            dialog = Gtk.MessageDialog(
                    self.window, 0, Gtk.MessageType.QUESTION,
                    Gtk.ButtonsType.YES_NO,
                    "Are you sure to remove the delivery note item?"
                    )

            if dialog.run() == Gtk.ResponseType.YES:
                self.delete_delivery_note_item(delivery_note_item)
                self.update_total()

            dialog.destroy()
        else:
            self.populate_delivery_note_items_form(delivery_note_item)
コード例 #2
0
ファイル: helper.py プロジェクト: rmunoz/sigg
def populate_db():
    v12 = Vehicle(
            number=12, plate="1234ABC", brand="My brand",
            model="My model", hour_price=27.32, km_price=8.99
            )
    v15 = Vehicle(
            number=15, plate="9876ZYX", brand="My brand",
            model="My model", hour_price=34.02, km_price=4.00
            )
    v12.save()
    v15.save()

    c1 = Company(
            code="0001", name="Company name", nif="B12345678",
            address="Rue st.", city="Zaragoza", state="Zaragoza",
            zip_code="50000", phone="123456789", contact_person="Foolano",
            alternative_phone="987654321", fax="246813579",
            email="*****@*****.**", iban="ES12345678901234567890123456789012",
            bank_name="THE Bank", payment_type="CASH", expiration_days=30,
            first_payment_day=5, second_payment_day=15, third_payment_day=25
            )

    c2 = Company(
            code="0002", name="Foo Inc.", nif="B45678123",
            address="Major st", city="Zaragoza", state="Zaragoza",
            zip_code="50002", email="*****@*****.**",
            iban="ES12345678901234567890123456789012", bank_name="Minor Bank",
            payment_type="BANK_TRANSFER", expiration_days=45,
            first_payment_day=8
            )

    c1.save()
    c2.save()

    dn1 = DeliveryNote(
            code="11111111", date=date(2016, 1, 3), company=c1, vehicle=v12,
            invoiced=False
            )
    dn2 = DeliveryNote(
            code="22222222", date=date(2016, 1, 5), company=c1, vehicle=v15,
            invoiced=False
            )
    dn1.save()
    dn2.save()

    dni1 = DeliveryNoteItem(
            delivery_note=dn1, item_type="HOURS", units=12,
            price=v12.hour_price, description="Working hard"
            )
    dni2 = DeliveryNoteItem(
            delivery_note=dn2, item_type="HOURS", units=7,
            price=21.00, description="We are working hard here"
            )
    dni3 = DeliveryNoteItem(
            delivery_note=dn2, item_type="OTHERS", units=1,
            price=327.86, description="Are you working hard?"
            )
    dni1.save()
    dni2.save()
    dni3.save()

    Settings(vat=21.00, invoice_number="0000000001").save()