Bug 726430 - Python: account.getName() raises TypeError

This particular commit fixes the new_book_with_opening_balances.py example script.
This commit is contained in:
Geert Janssens 2014-03-19 17:05:46 +01:00
parent 67d90c90cc
commit 2215e3826e
3 changed files with 6 additions and 5 deletions

View File

@ -140,7 +140,7 @@ def account_from_path(top_account, account_path, original_path=None):
account, account_path = account_path[0], account_path[1:]
account = top_account.lookup_by_name(account)
if account.get_instance() == None:
if account == None:
raise Exception(
"path " + ''.join(original_path) + " could not be found")
if len(account_path) > 0 :

View File

@ -21,7 +21,6 @@ def mark_account_with_code_as_tax_related(account, target_code):
return True
else:
for child in account.get_children():
child = Account(instance=child)
if mark_account_with_code_as_tax_related(child, target_code):
return True
return False

View File

@ -178,7 +178,7 @@ def recursivly_build_account_tree(original_parent_account,
account_types_to_open ):
for child in original_parent_account.get_children():
original_account = Account(instance=child)
original_account = child
new_account = Account(new_book)
# attach new account to its parent
new_parent_account.append_child(new_account)
@ -195,7 +195,9 @@ def recursivly_build_account_tree(original_parent_account,
namespace = orig_commodity.get_namespace()
mnemonic = orig_commodity.get_mnemonic()
new_commodity = new_commodity_table.lookup(namespace, mnemonic)
assert(new_commodity.get_instance() != None )
if new_commodity == None:
new_commodity = orig_commodity.clone(new_book)
new_commodity_table.insert(new_commodity)
new_account.SetCommodity(new_commodity)
record_opening_balance( original_account, new_account,
@ -220,7 +222,7 @@ def find_or_make_account(account_tuple, root_account, book,
currency ):
current_account_name, account_path = account_tuple[0], account_tuple[1:]
current_account = root_account.lookup_by_name(current_account_name)
if current_account.get_instance() == None:
if current_account == None:
current_account = Account(book)
current_account.SetName(current_account_name)
current_account.SetCommodity(currency)