From b89723a561d3c5efdee13eeca35bc6132d89eee8 Mon Sep 17 00:00:00 2001 From: Mike Evans Date: Thu, 3 Mar 2016 12:13:36 +0000 Subject: [PATCH] Bug 762971 - Duplicating multiple invoices results in invoices without an ID number If a duplicated invoice doesn't have an ID (which it won't if multiple invoices are duplicated) allocate it (them) the next ID. --- src/business/business-gnome/dialog-invoice.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/business/business-gnome/dialog-invoice.c b/src/business/business-gnome/dialog-invoice.c index 8bf4448176..c5b2b6e74e 100644 --- a/src/business/business-gnome/dialog-invoice.c +++ b/src/business/business-gnome/dialog-invoice.c @@ -2695,7 +2695,7 @@ set_gncEntry_date(gpointer data, gpointer user_data) InvoiceWindow * gnc_ui_invoice_duplicate (GncInvoice *old_invoice, gboolean open_properties, const GDate *new_date) { - InvoiceWindow *iw; + InvoiceWindow *iw = NULL; GncInvoice *new_invoice = NULL; GDate new_date_gdate; @@ -2746,10 +2746,14 @@ InvoiceWindow * gnc_ui_invoice_duplicate (GncInvoice *old_invoice, gboolean open } else { - // Open the newly created invoice in the "edit" window + // Open the newly created invoice in the "edit" window iw = gnc_ui_invoice_edit (new_invoice); + // Check the ID; set one if necessary + if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (iw->id_entry)), "") == 0) + { + gncInvoiceSetID (new_invoice, gncInvoiceNextID(iw->book, &(iw->owner))); + } } - return iw; }