Helpdesk installing on existing site error

(env) sukhpreet:~/frappe-bench/sites$ bench --site books.localhost install-app helpdesk

Installing helpdesk...
Updating DocTypes for helpdesk      : [==                  ] 13%An error occurred while installing helpdesk: name 'Document' is not defined
Traceback with variables (most recent call last):
  File "apps/frappe/frappe/commands/site.py", line 478, in install_app
    _install_app(app, verbose=context.verbose, force=force)
      context = {'sites': ['books.localhost'], 'force': False, 'verbose': False, 'profile': False}
      apps = ('helpdesk',)
      force = False
      _install_app = <function install_app at 0x77ad9be33600>
      filelock = <function filelock at 0x77ad9be31300>
      exit_code = 0
      site = 'books.localhost'
      app = 'helpdesk'
      err = NameError("name 'Document' is not defined")
  File "apps/frappe/frappe/installer.py", line 316, in install_app
    sync_for(name, force=force, reset_permissions=True)
      name = 'helpdesk'
      verbose = False
      set_as_patched = True
      force = False
      sync_jobs = <function sync_jobs at 0x77ad9b127ce0>
      sync_for = <function sync_for at 0x77ad9b13cae0>
      sync_customizations = <function sync_customizations at 0x77ad9c9f5120>
      sync_fixtures = <function sync_fixtures at 0x77ad9b13ce00>
      app_hooks = {'add_to_apps_screen': [{'name': 'helpdesk', 'logo': '/assets/helpdesk/desk/favicon.svg', 'title': 'Helpdesk', 'route': '/helpdesk', 'has_permission': 'helpdesk.api.permission.has_app_permission'}], 'after_install': ['helpdesk.setup.install.after_install'], 'after_migrate': ['helpdesk.search.build_index_in_background', 'helpdesk.search.download_corpus'], 'app_color': ['grey'], 'app_description': ['Customer Service Software'], 'app_email': ['hello@frappe.io'], 'app_icon': ['octicon octicon-file-directory'], 'app_license': ['AGPLv3'], 'app_name': ['helpdesk'], 'app_publisher': ['Frappe Technologies'], 'app_title': ['Helpdesk'], 'doc_events': {'Contact': {'before_insert': ['helpdesk.helpdesk.hooks.contact.before_insert']}, 'Assignment Rule': {'on_trash': ['helpdesk.extends.assignment_rule.on_assignment_rule_trash']}}, 'has_permission': {'HD Ticket': ['helpdesk.helpdesk.doctype.hd_ticket.hd_ticket.has_permission']}, 'ignore_links_on_delete': ['HD Notification', 'HD Ticket Comment'], 'overr...
      installed_apps = ['frappe', 'books_management']
  File "apps/frappe/frappe/model/sync.py", line 111, in sync_for
    import_file_by_path(
      app_name = 'helpdesk'
      force = False
      reset_permissions = True
      files = ['apps/helpdesk/helpdesk/helpdesk/doctype/hd_canned_response/hd_canned_response.json', 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_service_level_priority/hd_service_level_priority.json', 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_agent/hd_agent.json', 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_ticket_comment/hd_ticket_comment.json', 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_ticket_feedback_option/hd_ticket_feedback_option.json', 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_ticket_priority/hd_ticket_priority.json', 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/hd_article.json', 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_organization_contact_item/hd_organization_contact_item.json', 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_article_category/hd_article_category.json...
      module_name = 'helpdesk'
      folder = 'apps/helpdesk/helpdesk/helpdesk'
      l = 45
      i = 6
      doc_path = 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/hd_article.json'
  File "apps/frappe/frappe/modules/import_file.py", line 146, in import_file_by_path
    import_doc(
      path = 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/hd_article.json'
      force = False
      data_import = False
      pre_process = None
      ignore_version = True
      reset_permissions = True
      docs = [{'actions': [], 'allow_guest_to_view': 1, 'autoname': 'hash', 'creation': '2022-02-08 18:13:42.994713', 'doctype': 'DocType', 'editable_grid': 1, 'engine': 'InnoDB', 'fields': [{'allow_in_quick_entry': 1, 'fieldname': 'title', 'fieldtype': 'Data', 'in_list_view': 1, 'in_standard_filter': 1, 'label': 'Title', 'reqd': 1, 'doctype': 'DocField'}, {'default': 'Draft', 'fieldname': 'status', 'fieldtype': 'Select', 'in_standard_filter': 1, 'label': 'Status', 'options': 'Published\nDraft\nArchived', 'doctype': 'DocField'}, {'depends_on': 'eval:doc.status === "Published"', 'fieldname': 'published_on', 'fieldtype': 'Datetime', 'label': 'Published On', 'read_only': 1, 'doctype': 'DocField'}, {'default': '0', 'fieldname': 'views', 'fieldtype': 'Int', 'label': 'Views', 'read_only': 1, 'doctype': 'DocField'}, {'fieldname': 'column_break_7', 'fieldtype': 'Column Break', 'doctype': 'DocField'}, {'fieldname': 'category', 'fieldtype': 'Link', 'in_list_view': 1, 'label': 'Category', 'options': 'HD Artic...
      calculated_hash = '976e324fe80a6c825d8f13e15ab4aa30'
      doc = {'actions': [], 'allow_guest_to_view': 1, 'autoname': 'hash', 'creation': '2022-02-08 18:13:42.994713', 'doctype': 'DocType', 'editable_grid': 1, 'engine': 'InnoDB', 'fields': [{'allow_in_quick_entry': 1, 'fieldname': 'title', 'fieldtype': 'Data', 'in_list_view': 1, 'in_standard_filter': 1, 'label': 'Title', 'reqd': 1, 'doctype': 'DocField'}, {'default': 'Draft', 'fieldname': 'status', 'fieldtype': 'Select', 'in_standard_filter': 1, 'label': 'Status', 'options': 'Published\nDraft\nArchived', 'doctype': 'DocField'}, {'depends_on': 'eval:doc.status === "Published"', 'fieldname': 'published_on', 'fieldtype': 'Datetime', 'label': 'Published On', 'read_only': 1, 'doctype': 'DocField'}, {'default': '0', 'fieldname': 'views', 'fieldtype': 'Int', 'label': 'Views', 'read_only': 1, 'doctype': 'DocField'}, {'fieldname': 'column_break_7', 'fieldtype': 'Column Break', 'doctype': 'DocField'}, {'fieldname': 'category', 'fieldtype': 'Link', 'in_list_view': 1, 'label': 'Category', 'options': 'HD Articl...
      db_modified_timestamp = None
      is_db_timestamp_latest = None
  File "apps/frappe/frappe/modules/import_file.py", line 239, in import_doc
    doc.insert()
      docdict = {'actions': [], 'allow_guest_to_view': 1, 'autoname': 'hash', 'creation': '2022-02-08 18:13:42.994713', 'doctype': 'DocType', 'editable_grid': 1, 'engine': 'InnoDB', 'fields': [{'allow_in_quick_entry': 1, 'fieldname': 'title', 'fieldtype': 'Data', 'in_list_view': 1, 'in_standard_filter': 1, 'label': 'Title', 'reqd': 1, 'doctype': 'DocField'}, {'default': 'Draft', 'fieldname': 'status', 'fieldtype': 'Select', 'in_standard_filter': 1, 'label': 'Status', 'options': 'Published\nDraft\nArchived', 'doctype': 'DocField'}, {'depends_on': 'eval:doc.status === "Published"', 'fieldname': 'published_on', 'fieldtype': 'Datetime', 'label': 'Published On', 'read_only': 1, 'doctype': 'DocField'}, {'default': '0', 'fieldname': 'views', 'fieldtype': 'Int', 'label': 'Views', 'read_only': 1, 'doctype': 'DocField'}, {'fieldname': 'column_break_7', 'fieldtype': 'Column Break', 'doctype': 'DocField'}, {'fieldname': 'category', 'fieldtype': 'Link', 'in_list_view': 1, 'label': 'Category', 'options': 'HD Articl...
      data_import = False
      pre_process = None
      ignore_version = True
      reset_permissions = True
      path = 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/hd_article.json'
      controller = <class 'frappe.core.doctype.doctype.doctype.DocType'>
      doc = <DocType: HD Article>
  File "apps/frappe/frappe/model/document.py", line 320, in insert
    self.run_post_save_methods()
      self = <DocType: HD Article>
      ignore_permissions = None
      ignore_links = None
      ignore_if_duplicate = False
      ignore_mandatory = None
      set_name = None
      set_child_names = True
      d = <DocPerm: rin1k4e0oi parent=HD Article>
  File "apps/frappe/frappe/model/document.py", line 1140, in run_post_save_methods
    self.run_method("on_update")
      self = <DocType: HD Article>
  File "apps/frappe/frappe/model/document.py", line 974, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
      self = <DocType: HD Article>
      method = 'on_update'
      args = ()
      kwargs = {}
      fn = <function Document.run_method.<locals>.fn at 0x77ad8d37bba0>
  File "apps/frappe/frappe/model/document.py", line 1334, in composer
    return composed(self, method, *args, **kwargs)
      self = <DocType: HD Article>
      args = ()
      kwargs = {}
      hooks = [<function build_domain_restriced_doctype_cache at 0x77ad9c325da0>, <function clear_doctype_notifications at 0x77ad9d7d6e80>, <function process_workflow_actions at 0x77ad8d430ae0>, <function attach_files_to_document at 0x77ad9cd9ef20>, <function apply at 0x77ad8d433920>, <function update_due_date at 0x77ad8d4339c0>, <function apply_permissions_for_non_standard_user_type at 0x77ad8d4451c0>]
      method = 'on_update'
      doc_events = {'*': {'on_update': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.core.doctype.file.utils.attach_files_to_document', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply', 'frappe.automation.doctype.assignment_rule.assignment_rule.update_due_date', 'frappe.core.doctype.user_type.user_type.apply_permissions_for_non_standard_user_type'], 'after_rename': ['frappe.desk.notifications.clear_doctype_notifications'], 'on_cancel': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply'], 'on_trash': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions'], 'on_update_after_submit': ['frappe.workflow.doctype.workflow_action.workflow_action.process_w...
      handler = 'frappe.core.doctype.user_type.user_type.apply_permissions_for_non_standard_user_type'
      composed = <function Document.hook.<locals>.compose.<locals>.runner at 0x77ad8d37bd80>
      compose = <function Document.hook.<locals>.compose at 0x77ad8d37bf60>
      f = <function Document.run_method.<locals>.fn at 0x77ad8d37bba0>
  File "apps/frappe/frappe/model/document.py", line 1316, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
      self = <DocType: HD Article>
      method = 'on_update'
      args = ()
      kwargs = {}
      add_to_return_value = <function Document.hook.<locals>.add_to_return_value at 0x77ad8d37bc40>
      fn = <function Document.run_method.<locals>.fn at 0x77ad8d37bba0>
      hooks = (<function build_domain_restriced_doctype_cache at 0x77ad9c325da0>, <function clear_doctype_notifications at 0x77ad9d7d6e80>, <function process_workflow_actions at 0x77ad8d430ae0>, <function attach_files_to_document at 0x77ad9cd9ef20>, <function apply at 0x77ad8d433920>, <function update_due_date at 0x77ad8d4339c0>, <function apply_permissions_for_non_standard_user_type at 0x77ad8d4451c0>)
  File "apps/frappe/frappe/model/document.py", line 971, in fn
    return method_object(*args, **kwargs)
      self = <DocType: HD Article>
      args = ()
      kwargs = {}
      method_object = <bound method DocType.on_update of <DocType: HD Article>>
      method = 'on_update'
  File "apps/frappe/frappe/core/doctype/doctype/doctype.py", line 531, in on_update
    self.run_module_method("on_doctype_update")
      self = <DocType: HD Article>
      allow_doctype_export = False
  File "apps/frappe/frappe/core/doctype/doctype/doctype.py", line 629, in run_module_method
    module = load_doctype_module(self.name, self.module)
      self = <DocType: HD Article>
      method = 'on_doctype_update'
      load_doctype_module = <function load_doctype_module at 0x77ad9c9f5760>
  File "apps/frappe/frappe/modules/utils.py", line 254, in load_doctype_module
    doctype_python_modules[key] = frappe.get_module(module_name)
      doctype = 'HD Article'
      module = 'Helpdesk'
      prefix = ''
      suffix = ''
      app = 'helpdesk'
      key = ********
      module_name = 'helpdesk.helpdesk.doctype.hd_article.hd_article'
  File "apps/frappe/frappe/__init__.py", line 1434, in get_module
    return importlib.import_module(modulename)
      modulename = 'helpdesk.helpdesk.doctype.hd_article.hd_article'
  File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
      name = 'helpdesk.helpdesk.doctype.hd_article.hd_article'
      package = None
      level = 0
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
      name = 'helpdesk.helpdesk.doctype.hd_article.hd_article'
      package = None
      level = 0
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
      name = 'helpdesk.helpdesk.doctype.hd_article.hd_article'
      import_ = <function _gcd_import at 0x77ad9e7a40e0>
      module = <exception while printing> Traceback (most recent call last):
          File "env/lib/python3.12/site-packages/traceback_with_variables/core.py", line 222, in _to_cropped_str
            raw = print_(obj)
                  ^^^^^^^^^^^
          File "apps/frappe/frappe/utils/__init__.py", line 328, in dict_printer
            if key in v:
               ^^^^^^^^
        TypeError: argument of type 'object' is not iterable
        
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
      name = 'helpdesk.helpdesk.doctype.hd_article.hd_article'
      import_ = <function _gcd_import at 0x77ad9e7a40e0>
      path = ['apps/helpdesk/helpdesk/helpdesk/doctype/hd_article']
      parent = 'helpdesk.helpdesk.doctype.hd_article'
      parent_spec = ModuleSpec(name='helpdesk.helpdesk.doctype.hd_article', loader=<_frozen_importlib_external.SourceFileLoader object at 0x77ad8d3a0830>, origin='apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/__init__.py', submodule_search_locations=['apps/helpdesk/helpdesk/helpdesk/doctype/hd_article'])
      parent_module = <module 'helpdesk.helpdesk.doctype.hd_article' from 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/__init__.py'>
      child = 'hd_article'
      spec = ModuleSpec(name='helpdesk.helpdesk.doctype.hd_article.hd_article', loader=<_frozen_importlib_external.SourceFileLoader object at 0x77ad8d3a07a0>, origin='apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/hd_article.py')
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
      spec = ModuleSpec(name='helpdesk.helpdesk.doctype.hd_article.hd_article', loader=<_frozen_importlib_external.SourceFileLoader object at 0x77ad8d3a07a0>, origin='apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/hd_article.py')
      module = <module 'helpdesk.helpdesk.doctype.hd_article.hd_article' from 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/hd_article.py'>
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
      self = <_frozen_importlib_external.SourceFileLoader object at 0x77ad8d3a07a0>
      module = <module 'helpdesk.helpdesk.doctype.hd_article.hd_article' from 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/hd_article.py'>
      code = <code object <module> at 0x77ad8d229470, file "apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/hd_article.py", line 1>
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
      f = <built-in function exec>
      args = (<code object <module> at 0x77ad8d229470, file "apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/hd_article.py", line 1>, {'__name__': 'helpdesk.helpdesk.doctype.hd_article.hd_article', '__doc__': None, '__package__': 'helpdesk.helpdesk.doctype.hd_article', '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x77ad8d3a07a0>, '__spec__': ModuleSpec(name='helpdesk.helpdesk.doctype.hd_article.hd_article', loader=<_frozen_importlib_external.SourceFileLoader object at 0x77ad8d3a07a0>, origin='apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/hd_article.py'), '__file__': 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/hd_article.py', '__cached__': 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/__pycache__/hd_article.cpython-312.pyc', '__builtins__': {'__name__': 'builtins', '__doc__': "Built-in functions, types, exceptions, and other objects.\n\nThis module provides di...
      kwds = {}
  File "apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/hd_article.py", line 12, in <module>
    class HDArticle(Document):
      __name__ = 'helpdesk.helpdesk.doctype.hd_article.hd_article'
      __doc__ = None
      __package__ = 'helpdesk.helpdesk.doctype.hd_article'
      __loader__ = <_frozen_importlib_external.SourceFileLoader object at 0x77ad8d3a07a0>
      __spec__ = ModuleSpec(name='helpdesk.helpdesk.doctype.hd_article.hd_article', loader=<_frozen_importlib_external.SourceFileLoader object at 0x77ad8d3a07a0>, origin='apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/hd_article.py')
      __file__ = 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/hd_article.py'
      __cached__ = 'apps/helpdesk/helpdesk/helpdesk/doctype/hd_article/__pycache__/hd_article.cpython-312.pyc'
      __builtins__ = {'__name__': 'builtins', '__doc__': "Built-in functions, types, exceptions, and other objects.\n\nThis module provides direct access to all 'built-in'\nidentifiers of Python; for example, builtins.len is\nthe full name for the built-in function len().\n\nThis module is not normally accessed explicitly by most\napplications, but can be useful in modules that provide\nobjects with the same name as a built-in value, but in\nwhich the built-in of that name is also needed.", '__package__': '', '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>, origin='built-in'), '__build_class__': <built-in function __build_class__>, '__import__': <built-in function __import__>, 'abs': <built-in function abs>, 'all': <built-in function all>, 'any': <built-in function any>, 'ascii': <built-in function ascii>, 'bin': <built-in function bin>, 'breakpoint': <built-in function breakpoint>, 'callable': <built-in f...
      frappe = <module 'frappe' from 'apps/frappe/frappe/__init__.py'>
      _ = <function _ at 0x77ad9d835580>
      WebsiteGenerator = <class 'frappe.website.website_generator.WebsiteGenerator'>
      cint = <function cint at 0x77ad9d6618a0>
      capture_event = <function capture_event at 0x77ad8d55f920>
builtins.NameError: name 'Document' is not defined