AttributeError: 'unicode' object has no attribute 'group_or_ledger'

This is the error message:
Traceback (innermost last):
File “/home/erpnext/frappe-bench/apps/frappe/frappe/”, line 49, in application
response = frappe.handler.handle()
File “/home/erpnext/frappe-bench/apps/frappe/frappe/”, line 66, in handle
File “/home/erpnext/frappe-bench/apps/frappe/frappe/”, line 89, in execute_cmd
ret =, **frappe.form_dict)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/”, line 531, in call
return fn(*args, **newargs)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/”, line 19, in runserverobj
frappe.widgets.form.run_method.runserverobj(method, docs=docs, dt=dt, dn=dn, arg=arg, args=args)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/widgets/form/”, line 35, in runserverobj
r = doc.run_method(method)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/model/”, line 453, in run_method
return Document.hook(fn)(self, *args, **kwargs)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/model/”, line 534, in composer
return composed(self, method, *args, **kwargs)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/model/”, line 517, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/erpnext/frappe-bench/apps/frappe/frappe/model/”, line 447, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/erpnext/frappe-bench/apps/erpnext/erpnext/accounts/doctype/budget_allocation/”, line 93, in get_Budget
if str(ai.group_or_ledger()) == “Ledger”:
AttributeError: ‘unicode’ object has no attribute ‘group_or_ledger’

This is my code:

if str(ai.group_or_ledger) == "Ledger":
					bgColor = """ bgcolor="#FF0000" """
					normal = """font-weight: normal;"""
				indent = 20
				html +="""<tr><td style='"""+normal+"""text-indent: """+str(flt(indent)*flt(ai.indent))+"""px;white-space: nowrap;'>"""+str(ai.account_name)+"""</td>"""
				html += """"""

Thank you! I’ve been doing this for how many days.

can you please share your whole code and can you tell me what you’re trying to do here?