gnucash maint: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Mon Dec 24 16:49:26 EST 2018
Updated via https://github.com/Gnucash/gnucash/commit/d97508d0 (commit)
via https://github.com/Gnucash/gnucash/commit/5675dad2 (commit)
from https://github.com/Gnucash/gnucash/commit/aaeb639d (commit)
commit d97508d0ac27a1dd90c07d8eb879cbf3f071da8a
Merge: aaeb639 5675dad
Author: John Ralls <jralls at ceridwen.us>
Date: Mon Dec 24 13:45:10 2018 -0800
Merge Frank Oltmans's 'py_get_all_customers' into maint.
commit 5675dad2f36c0b263e7dc398e138ac38834551c9
Author: Frank Oltmanns <frank.oltmanns+github at gmail.com>
Date: Sat Nov 17 13:12:17 2018 +0100
Update query for get_all_customers
Use same time of query in get_all_customers as in get_all_invoices
diff --git a/bindings/python/example_scripts/gncinvoicefkt.py b/bindings/python/example_scripts/gncinvoicefkt.py
index 8caaa57..28efed5 100644
--- a/bindings/python/example_scripts/gncinvoicefkt.py
+++ b/bindings/python/example_scripts/gncinvoicefkt.py
@@ -56,7 +56,7 @@ def get_all_invoices_from_lots(account):
def get_all_invoices(book, is_paid=None, is_active=None):
"""Returns a list of all invoices in the book.
- posts a query to search for all invoices.
+ Posts a query to search for all invoices.
arguments:
book the gnucash book to work with
@@ -90,7 +90,6 @@ def get_all_invoices(book, is_paid=None, is_active=None):
invoice_list = []
- result = query.run()
for result in query.run():
invoice_list.append(Invoice(instance=result))
@@ -101,16 +100,21 @@ def get_all_invoices(book, is_paid=None, is_active=None):
def get_all_customers(book):
"""Returns all customers in book.
- Counts IDs upwards. May miss customers with irregular IDs.
- Should be replaced by query as in get_all_invoices."""
+ Posts a query to search for all customers.
+
+ arguments:
+ book the gnucash book to work with
+ """
+
+ query = gnucash.Query()
+ query.search_for('gncCustomer')
+ query.set_book(book)
customer_list = []
- customer = True
- customer_id = 0
- while customer:
- customer_id += 1
- customer = book.CustomerLookupByID('%06d' % customer_id)
- if customer:
- customer_list.append(customer)
+
+ for result in query.run():
+ customer_list.append(Customer(instance=result))
+
+ query.destroy()
return customer_list
Summary of changes:
bindings/python/example_scripts/gncinvoicefkt.py | 26 ++++++++++++++----------
1 file changed, 15 insertions(+), 11 deletions(-)
More information about the gnucash-changes
mailing list