List all customers with Python bindings

Tom Lofts dev at loftx.co.uk
Tue Jun 4 04:36:56 EDT 2013


Hi Jonas,

Gnucash uses the Query Object Framework (http://svn.gnucash.org/docs/HEAD/group__QOF.html) to return a number of customers (or other types of data) and allows various conditions to be applied to the data returned.

Unfortunately I believe this is not completely implemented in the Python bindings yet, though I have made a start over the last month, so that it is not possible to return the information you require.

You'll need to be using the unstable Gnucash release (at least 2.5.1), as this has a number of additional functions in the Query class you'll need to use. You should then find you can use the following:

query = gnucash.Query()
query.search_for('gncCustomer')
query.set_book(book)
customers = []

for result in query.run():
	customers.append(gnucash.gnucash_business.Customer(instance=result))

query.destroy()

Which will return you a list of Customer objects if you pass a Book Object into query.set_book()

This code comes from the REST API example at https://github.com/Gnucash/gnucash/tree/trunk/src/optional/python-bindings/example_scripts/rest-api which I have been working on so you may find some more help here.

Kind regards,

Tom

-----Original Message-----
From: gnucash-devel-bounces+dev=loftx.co.uk at gnucash.org [mailto:gnucash-devel-bounces+dev=loftx.co.uk at gnucash.org] On Behalf Of Jonas Lippuner
Sent: 03 June 2013 09:57
To: gnucash-devel at gnucash.org
Subject: List all customers with Python bindings

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear Developers,

How do I get a list of all customers (or all vendors, invoices, bills
etc.) using the Python bindings? I see from examples how I can get a specific customer using book.LookupByID, but this requires that I know the GUID of the customer.

Alternatively, is there a way to get a list of all GUIDs? Then I can simply go through all of them and filter out the customers...


Thanks,
Jonas

- --
My email is signed and I encrypt email on request.
To verify my signature or send me encrypted email, get my public key: http://lippuner.ca/key -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJRrFpDAAoJELH92qHy0gntuH0P/1rx6ZIB+kEV5ddxl3ZYYpIJ
GBpUz0JltsadFAOuVWG6SjxyiK8so+KQsW1PPcTnq93qL0J55XGWtHEV0LR0kyyf
HGUJlUJ1djjPLQAa7VxAVOJ+QmdTMMFiJ8jCoxIW6Aa94C95qSnPntW2pYlHQseS
ScJC25OeNErcohM8szlMLOzCpNR9L7B1PudokKsi6touphKZ3AEFJ0xxdBw25Ks0
cRpNLQwGM5qBIqwucD0OFKx0PfI/pWO7Oi7x3DXSNU3wrFYD8YzvmHn/2jiTWbMu
j6336NQYCKRd/RczgIJgMR4LoYXk+O9fxecUyehl3MVyP7GBn5E3nTXXGeSAQHxl
VNbMzTWKSFD6MwPEtnBecPyOlJcf1jS/r3EYPtTn7zytrNne41IHl+dTs3qBZ3Tt
HW9jSp5w2oDck6JGdB1hDIRbmVsNOb3fhsNGbUwWtywkgtOgRWaDy5yUjEJ660Jt
8rnYRLcLkZ+oXW1Qt9haW13XZHRmYpDy16pt1OzB8U31ZMtp/dqBk85CGFiNQZaV
mArh27ZIkUbwCwbfLq3/cDijAzBLvh4+6/NsZgc/rBmlM6z6hcbvg5eHMCaovTf5
LPCVt74901QwM3MpDvoVgOs/DIrX9Ean4pspvjS/Z5DfW1sxWoVTWNH3Va7/x57d
vV0gA+ugVRCEbYzFYu8P
=/c+E
-----END PGP SIGNATURE-----
_______________________________________________
gnucash-devel mailing list
gnucash-devel at gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel





More information about the gnucash-devel mailing list