GNOME Bugzilla – Bug 625193
Added 'search by ID' for invoices, customers and bills.
Last modified: 2018-06-29 22:42:12 UTC
Created attachment 166490 [details] [review] Adds search by Invoice_Bill_Customer_ID to python bindings When creating or appending to invoices, customers and bills, searching by ID is likely more useful than by GUID. I've added this functionality to the Python bindings. Search by ID using the python code: tmp = gnucash.gnucash_core_c.search_invoice_on_id(ID,book.instance) if tmp: invoice = gnucash.gnucash_business.Invoice(instance=tmp) Use the invoice object as in sample_scripts/simple_invoice_insert.py
Comment on attachment 166490 [details] [review] Adds search by Invoice_Bill_Customer_ID to python bindings (But there is a small typo in src/optional/python-bindings/Makefile.am in the second-to-last hunk where "xample_scripts" is missing an "e".)
Created attachment 166754 [details] [review] Patch for python bindings to add search by ID Corrects typo in previous patch.
Created attachment 167010 [details] [review] Enhanced patch that supports searching for Customer, Invoice, and Bill by ID I support this patch, but I've made a few improvments of my own. I switched up the arguments in search_customer_on_id, search_invoice_on_id, search_bill_on_id to have Book first and ID second. The reason for this was to make these functions more consistent with the other functions where a search is done through a book on a particular attribute. Also added some specific python bindings support to allow this to be used as methods of Book: Book.CustomerLookupByID, Book.InvoiceLookupByID, Book.BillLoookupByID. In the Makefile I removed the dependancy for gnucash_core.c and gnucash_core_c.py on utils.c. Neither of these files have utils.c as a dependency for thier creation. The actual binary library file that is created by compiling gnucash_core.c and utils.c has the dependency on utils.c and utils.h; and Automake already takes care of that via the appearance of utils.c in _gnucash_core_c_la_SOURCES.
> I support this patch What I mean is, I support this patch being commited to trunk. (can't do that myself) I've commited this my own svn repository http://svn.parit.ca/gnucash/branches/python-bindings@579 http://svn.parit.ca/gnucash/branches/python-bindings-invoicesearch@578
Makes sense to me. Maybe my choice of utils.c as a file name could have been better though.
It's also possible that such searching C code (as found in utils.c) should have a place in gnucash generally and not the python bindings specifically so it can be available to users of the GnuCash C api and other future language bindings that come along. (the python bindings would just link to and use it like the rest of the C api instead of hard building it into the python bindings module) No language binding specific C code appears in utils.c, which does kind of imply that it shouldn't be included in the language binding module specifically. But that can be done another time. For now this could be applied and refined later.
I agree that it is a useful function to add to the core code. For the origin and proper attribution of the code see Bug 624911. Perhaps a little late to include it so near to a 2.4 release though?
Comment on attachment 167010 [details] [review] Enhanced patch that supports searching for Customer, Invoice, and Bill by ID r19431
Thanks a lot! (Moving the general functions from optional to the core is a good idea. This can even be done while we're in the preparation of 2.4.0, because the new function isn't used anywhere inside the rest of gnucash. Just go ahead and submit a patch. Thanks!)
Would Mark be willing to do that? I am a bit vague as to where to insert this and as to proper naming conventions for core functions etc. N.B. This crosses over with Bug 624911.
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=625193. Please update any external references or bookmarks.