kid1194 / erpnext_expenses

An expenses management module for ERPNext.
MIT License
22 stars 30 forks source link

install-app expenses happens errors #10

Closed guinanlin closed 1 month ago

guinanlin commented 1 month ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

on frappe+erpnext V15

frappe@38405fa4c504:~/frappe-bench$ bench --site site1.local install-app expenses
App erpnext already installed

Installing expenses...
An error occurred while installing expenses: Module import failed for Expense, the DocType you're trying to open might be deleted.<br> Error: cannot import name 'get_current_exchange_rate' from 'expenses.libs.entry' (/home/frappe/frappe-bench/apps/expenses/expenses/libs/entry.py)
Traceback with variables (most recent call last):
  File "apps/frappe/frappe/commands/site.py", line 445, in install_app
    _install_app(app, verbose=context.verbose, force=force)
      context = {'sites': ['site1.local'], 'force': False, 'verbose': False, 'profile': False}
      apps = ('expenses',)
      force = False
      _install_app = <function install_app at 0x7fd923cf25f0>
      filelock = <function filelock at 0x7fd923cf2290>
      exit_code = 0
      site = 'site1.local'
      app = 'expenses'
      err = ImportError("Module import failed for Expense, the DocType you're trying to open might be deleted.<br> Error: cannot import name 'get_current_exchange_rate' from 'expenses.libs.entry' (apps/expenses/expenses/libs/entry.py)")
  File "apps/frappe/frappe/installer.py", line 301, in install_app
    sync_for(name, force=force, reset_permissions=True)
      name = 'expenses'
      verbose = False
      set_as_patched = True
      force = False
      sync_jobs = <function sync_jobs at 0x7fd922c44ca0>
      sync_for = <function sync_for at 0x7fd922c45750>
      sync_customizations = <function sync_customizations at 0x7fd923c95000>
      sync_fixtures = <function sync_fixtures at 0x7fd922c45990>
      app_hooks = {'after_migrate': ['expenses.setup.migrate.after_migrate'], 'after_sync': ['expenses.setup.install.after_sync'], 'after_uninstall': ['expenses.setup.uninstall.after_uninstall'], 'app_color': ['blue'], 'app_description': ['An expenses management module for ERPNext.'], 'app_email': ['kid1194@gmail.com'], 'app_icon': ['octicon octicon-note'], 'app_license': ['MIT'], 'app_name': ['expenses'], 'app_publisher': ['Ameen Ahmed (Level Up)'], 'app_title': ['Expenses'], 'before_install': ['expenses.setup.install.before_install'], 'doctype_js': {'Expenses Settings': ['public/js/expenses.bundle.js'], 'Expense Type': ['public/js/expenses.bundle.js'], 'Expense Item': ['public/js/expenses.bundle.js'], 'Expense': ['public/js/expenses.bundle.js'], 'Expenses Request': ['public/js/expenses.bundle.js'], 'Expenses Entry': ['public/js/expenses.bundle.js']}, 'doctype_list_js': {'Expense Item': ['public/js/expenses.bundle.js'], 'Expense Type': ['public/js/expenses.bundle.js'], 'Expense': ['public/js/expenses.b...
      installed_apps = ['frappe', 'erpnext', 'hrms', 'print_designer']
      app = 'erpnext'
      required_app = 'erpnext'
      before_install = 'expenses.setup.install.before_install'
      out = None
  File "apps/frappe/frappe/model/sync.py", line 111, in sync_for
    import_file_by_path(
      app_name = 'expenses'
      force = False
      reset_permissions = True
      files = ['apps/expenses/expenses/expenses/doctype/expense/expense.json', 'apps/expenses/expenses/expenses/doctype/expense_attachment/expense_attachment.json', 'apps/expenses/expenses/expenses/doctype/expense_item/expense_item.json', 'apps/expenses/expenses/expenses/doctype/expense_item_account/expense_item_account.json', 'apps/expenses/expenses/expenses/doctype/expense_type/expense_type.json', 'apps/expenses/expenses/expenses/doctype/expense_type_account/expense_type_account.json', 'apps/expenses/expenses/expenses/doctype/expenses_entry/expenses_entry.json', 'apps/expenses/expenses/expenses/doctype/expenses_entry_details/expenses_entry_details.json', 'apps/expenses/expenses/expenses/doctype/expenses_request/expenses_request.json', 'apps/e...
      module_name = 'expenses'
      folder = 'apps/expenses/expenses/expenses'
      l = 16
      i = 0
      doc_path = 'apps/expenses/expenses/expenses/doctype/expense/expense.json'
  File "apps/frappe/frappe/modules/import_file.py", line 146, in import_file_by_path
    import_doc(
      path = 'apps/expenses/expenses/expenses/doctype/expense/expense.json'
      force = False
      data_import = False
      pre_process = None
      ignore_version = True
      reset_permissions = True
      docs = [{'allow_copy': 0, 'allow_import': 1, 'autoname': 'format:EXP-{YY}{MM}{DD}-{###}', 'creation': '2023-04-04 04:04:04', 'description': 'Expense for Expenses module', 'doctype': 'DocType', 'engine': 'InnoDB', 'fields': [{'fieldname': 'main_section', 'fieldtype': 'Section Break', 'doctype': 'DocField'}, {'fieldname': 'company', 'fieldtype': 'Link', 'label': 'Company', 'options': 'Company', 'reqd': 1, 'bold': 1, 'remember_last_selected_value': 1, 'in_list_view': 1, 'in_filter': 1, 'in_standard_filter': 1, 'in_preview': 1, 'search_index': 1, 'ignore_user_permissions': 1, 'doctype': 'DocField'}, {'fieldname': 'expense_item', 'fieldtype': 'Link', 'label': 'Expense', 'options': 'Expense Item', 'reqd': 1, 'bold': 1, 'read_only_depends_on': 'eval:!doc.company', 'in_list_view': 1, 'in_filter': 1, 'in_standard_filter': 1, 'in_preview': 1, 'search_index': 1, 'ignore_user_permissions': 1, 'doctype': 'DocField'}, {'fieldname': 'expense_account', 'fieldtype': 'Link', 'label': 'Expense Account', 'option...
      calculated_hash = 'c7d77dae25d16ef075e464208021f00c'
      doc = {'allow_copy': 0, 'allow_import': 1, 'autoname': 'format:EXP-{YY}{MM}{DD}-{###}', 'creation': '2023-04-04 04:04:04', 'description': 'Expense for Expenses module', 'doctype': 'DocType', 'engine': 'InnoDB', 'fields': [{'fieldname': 'main_section', 'fieldtype': 'Section Break', 'doctype': 'DocField'}, {'fieldname': 'company', 'fieldtype': 'Link', 'label': 'Company', 'options': 'Company', 'reqd': 1, 'bold': 1, 'remember_last_selected_value': 1, 'in_list_view': 1, 'in_filter': 1, 'in_standard_filter': 1, 'in_preview': 1, 'search_index': 1, 'ignore_user_permissions': 1, 'doctype': 'DocField'}, {'fieldname': 'expense_item', 'fieldtype': 'Link', 'label': 'Expense', 'options': 'Expense Item', 'reqd': 1, 'bold': 1, 'read_only_depends_on': 'eval:!doc.company', 'in_list_view': 1, 'in_filter': 1, 'in_standard_filter': 1, 'in_preview': 1, 'search_index': 1, 'ignore_user_permissions': 1, 'doctype': 'DocField'}, {'fieldname': 'expense_account', 'fieldtype': 'Link', 'label': 'Expense Account', 'options...
      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 = {'allow_copy': 0, 'allow_import': 1, 'autoname': 'format:EXP-{YY}{MM}{DD}-{###}', 'creation': '2023-04-04 04:04:04', 'description': 'Expense for Expenses module', 'doctype': 'DocType', 'engine': 'InnoDB', 'fields': [{'fieldname': 'main_section', 'fieldtype': 'Section Break', 'doctype': 'DocField'}, {'fieldname': 'company', 'fieldtype': 'Link', 'label': 'Company', 'options': 'Company', 'reqd': 1, 'bold': 1, 'remember_last_selected_value': 1, 'in_list_view': 1, 'in_filter': 1, 'in_standard_filter': 1, 'in_preview': 1, 'search_index': 1, 'ignore_user_permissions': 1, 'doctype': 'DocField'}, {'fieldname': 'expense_item', 'fieldtype': 'Link', 'label': 'Expense', 'options': 'Expense Item', 'reqd': 1, 'bold': 1, 'read_only_depends_on': 'eval:!doc.company', 'in_list_view': 1, 'in_filter': 1, 'in_standard_filter': 1, 'in_preview': 1, 'search_index': 1, 'ignore_user_permissions': 1, 'doctype': 'DocField'}, {'fieldname': 'expense_account', 'fieldtype': 'Link', 'label': 'Expense Account', 'options...
      data_import = False
      pre_process = None
      ignore_version = True
      reset_permissions = True
      path = 'apps/expenses/expenses/expenses/doctype/expense/expense.json'
      controller = <class 'frappe.core.doctype.doctype.doctype.DocType'>
      doc = <DocType: Expense>
  File "apps/frappe/frappe/model/document.py", line 315, in insert
    self.run_post_save_methods()
      self = <DocType: Expense>
      ignore_permissions = None
      ignore_links = None
      ignore_if_duplicate = False
      ignore_mandatory = None
      set_name = None
      set_child_names = True
      d = <DocPerm: 2uu9ta0b5t parent=Expense>
  File "apps/frappe/frappe/model/document.py", line 1128, in run_post_save_methods
    self.run_method("on_update")
      self = <DocType: Expense>
  File "apps/frappe/frappe/model/document.py", line 962, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
      self = <DocType: Expense>
      args = ()
      kwargs = {}
      fn = <function Document.run_method.<locals>.fn at 0x7fd91ab089d0>
      method = 'on_update'
  File "apps/frappe/frappe/model/document.py", line 1322, in composer
    return composed(self, method, *args, **kwargs)
      self = <DocType: Expense>
      args = ()
      kwargs = {}
      hooks = [<function build_domain_restriced_doctype_cache at 0x7fd923c73eb0>, <function clear_doctype_notifications at 0x7fd91a8c9000>, <function process_workflow_actions at 0x7fd91a948670>, <function attach_files_to_document at 0x7fd922bd8f70>, <function apply at 0x7fd91a94b010>, <function update_due_date at 0x7fd91a94b0a0>, <function apply_permissions_for_non_standard_user_type at 0x7fd91a950940>]
      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 0x7fd91ab08dc0>
      compose = <function Document.hook.<locals>.compose at 0x7fd91ab08ee0>
      f = <function Document.run_method.<locals>.fn at 0x7fd91ab089d0>
  File "apps/frappe/frappe/model/document.py", line 1304, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
      self = <DocType: Expense>
      method = 'on_update'
      args = ()
      kwargs = {}
      add_to_return_value = <function Document.hook.<locals>.add_to_return_value at 0x7fd91ab091b0>
      fn = <function Document.run_method.<locals>.fn at 0x7fd91ab089d0>
      hooks = (<function build_domain_restriced_doctype_cache at 0x7fd923c73eb0>, <function clear_doctype_notifications at 0x7fd91a8c9000>, <function process_workflow_actions at 0x7fd91a948670>, <function attach_files_to_document at 0x7fd922bd8f70>, <function apply at 0x7fd91a94b010>, <function update_due_date at 0x7fd91a94b0a0>, <function apply_permissions_for_non_standard_user_type at 0x7fd91a950940>)
  File "apps/frappe/frappe/model/document.py", line 959, in fn
    return method_object(*args, **kwargs)
      self = <DocType: Expense>
      args = ()
      kwargs = {}
      method_object = <bound method DocType.on_update of <DocType: Expense>>
      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: Expense>
      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: Expense>
      method = 'on_doctype_update'
      load_doctype_module = <function load_doctype_module at 0x7fd923c955a0>
  File "apps/frappe/frappe/modules/utils.py", line 254, in load_doctype_module
    raise ImportError(msg) from e
      doctype = 'Expense'
      module = 'Expenses'
      prefix = ''
      suffix = ''
      app = 'expenses'
      key = ********
      module_name = 'expenses.expenses.doctype.expense.expense'
      msg = "Module import failed for Expense, the DocType you're trying to open might be deleted.<br> Error: cannot import name 'get_current_exchange_rate' from 'expenses.libs.entry' (apps/expenses/expenses/libs/entry.py)"
builtins.ImportError: Module import failed for Expense, the DocType you're trying to open might be deleted.<br> Error: cannot import name 'get_current_exchange_rate' from 'expenses.libs.entry' (apps/expenses/expenses/libs/entry.py)
guinanlin commented 1 month ago

research the error place : erpnext_expenses\expenses\libs__init__.py

from .entry import ( get_mode_of_payment_data, is_entry_moderator, entry_form_setup, get_current_exchange_rate, get_request_data )

kid1194 commented 1 month ago

@guinanlin Hey bro..

Thank you so much for reporting this.. I really appreciate it..

I have fixed my silly mistake and I hope that everything works well..

Best regards..