frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
21.82k stars 7.33k forks source link

bug: on bench <site> migrate -> ImportError: Module import failed for Video #21589

Closed AlvaroMolano closed 4 years ago

AlvaroMolano commented 4 years ago

Description of the issue:

After changing to develop branch: Executing erpnext.patches.v12_0.retain_permission_rules_for_video_doctype in (_04a1401eaea1b562) /data/safeuser/frappe/apps/frappe/frappe/core/doctype/video/video.json missing

On migrate command with bench: ImportError: Module import failed for Video (erpnext.education.doctype.video.video Error: No module named 'erpnext.education.doctype.video.video')

In the stack trace, there seems to be a recent refactoring moving video doctype from education into the core, added details at the end of this issue.

Context information (for bug reports)

Working in the develop branch On migrate, system all get broken Existing Video content in the system

Output of bench version

5.0.0

Steps to reproduce the issue

  1. Pull branch version-12
  2. Add in education Module a program -> Course -> Topic -> Video
  3. Change to the develop branch
  4. In console send the command: bench --site migrate
  5. In console send the command: bench serve (site is still in maintenance mode)
  6. Stop bench
  7. In console send the command: bench --site set-maintenance-mode off
  8. In console send the command: bench serve (site is still failing or in maintenance mode / no errors in the console)

Observed result

The system gets into maintenance mode Migration fails with error

Expected result

The system completes internal clean and updates Maintenance mode goes off No errors appear

Stacktrace / full error message

bench --site <sitename> migrate
Migrating <sitename>
Executing erpnext.patches.v12_0.update_is_cancelled_field in <sitename> (_04a1401eaea1b562)
Success: Done in 0.033s
Executing execute:frappe.delete_doc_if_exists("Report", "Loan Repayment") in <sitename> (_04a1401eaea1b562)
Success: Done in 1.298s
Executing erpnext.patches.v12_0.set_automatically_process_deferred_accounting_in_accounts_settings in <sitename> (_04a1401eaea1b562)
Success: Done in 0.152s
Executing erpnext.patches.v12_0.set_production_capacity_in_workstation in <sitename> (_04a1401eaea1b562)
Success: Done in 0.262s
Executing erpnext.patches.v12_0.set_employee_preferred_emails in <sitename> (_04a1401eaea1b562)
Success: Done in 0.05s
Executing erpnext.patches.v12_0.set_against_blanket_order_in_sales_and_purchase_order in <sitename> (_04a1401eaea1b562)
Success: Done in 0.767s
Executing erpnext.patches.v12_0.set_cost_center_in_child_table_of_expense_claim in <sitename> (_04a1401eaea1b562)
Success: Done in 0.229s
Executing erpnext.patches.v12_0.add_eway_bill_in_delivery_note in <sitename> (_04a1401eaea1b562)
Success: Done in 0.049s
Executing erpnext.patches.v12_0.set_lead_title_field in <sitename> (_04a1401eaea1b562)
Success: Done in 0.353s
Executing erpnext.patches.v12_0.set_published_in_hub_tracked_item in <sitename> (_04a1401eaea1b562)
Success: Done in 0.218s
Executing erpnext.patches.v12_0.set_job_offer_applicant_email in <sitename> (_04a1401eaea1b562)
Success: Done in 0.21s
Executing erpnext.patches.v12_0.move_bank_account_swift_number_to_bank in <sitename> (_04a1401eaea1b562)
Success: Done in 0.386s
Executing erpnext.patches.v12_0.rename_bank_reconciliation in <sitename> (_04a1401eaea1b562)
Success: Done in 0.022s
Executing erpnext.patches.v12_0.add_permission_in_lower_deduction in <sitename> (_04a1401eaea1b562)
Success: Done in 0.016s
Executing erpnext.patches.v12_0.rename_account_type_doctype in <sitename> (_04a1401eaea1b562)
Success: Done in 0.549s
Executing erpnext.patches.v12_0.update_healthcare_refactored_changes in <sitename> (_04a1401eaea1b562)
Success: Done in 2.903s
Executing erpnext.patches.v12_0.set_total_batch_quantity in <sitename> (_04a1401eaea1b562)
Success: Done in 0.261s
Executing erpnext.patches.v12_0.set_updated_purpose_in_pick_list in <sitename> (_04a1401eaea1b562)
Success: Done in 0.201s
Executing erpnext.patches.v12_0.set_default_payroll_based_on in <sitename> (_04a1401eaea1b562)
Success: Done in 0.132s
Executing erpnext.patches.v12_0.update_end_date_and_status_in_email_campaign in <sitename> (_04a1401eaea1b562)
Success: Done in 0.018s
Executing erpnext.patches.v13_0.move_tax_slabs_from_payroll_period_to_income_tax_slab #123 in <sitename> (_04a1401eaea1b562)
Success: Done in 0.668s
Executing erpnext.patches.v12_0.fix_quotation_expired_status in <sitename> (_04a1401eaea1b562)
Success: Done in 0.014s
Executing erpnext.patches.v12_0.update_appointment_reminder_scheduler_entry in <sitename> (_04a1401eaea1b562)
Success: Done in 0.021s
Executing erpnext.patches.v12_0.retain_permission_rules_for_video_doctype in <sitename> (_04a1401eaea1b562)
/data/safeuser/frappe/apps/frappe/frappe/core/doctype/video/video.json missing
Traceback (most recent call last):
  File "/data/safeuser/frappe/apps/frappe/frappe/modules/utils.py", line 204, in load_doctype_module
    doctype_python_modules[key] = frappe.get_module(module_name)
  File "/data/safeuser/frappe/apps/frappe/frappe/__init__.py", line 827, in get_module
    return importlib.import_module(modulename)
  File "/data/safeuser/frappe/env/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'erpnext.education.doctype.video.video'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/data/safeuser/frappe/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
  File "/data/safeuser/frappe/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/data/safeuser/frappe/env/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/data/safeuser/frappe/env/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/data/safeuser/frappe/env/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/data/safeuser/frappe/env/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/data/safeuser/frappe/env/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/data/safeuser/frappe/env/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/data/safeuser/frappe/env/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/data/safeuser/frappe/apps/frappe/frappe/commands/__init__.py", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/data/safeuser/frappe/apps/frappe/frappe/commands/site.py", line 239, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website, skip_failing=skip_failing)
  File "/data/safeuser/frappe/apps/frappe/frappe/migrate.py", line 48, in migrate
    frappe.modules.patch_handler.run_all(skip_failing)
  File "/data/safeuser/frappe/apps/frappe/frappe/modules/patch_handler.py", line 41, in run_all
    run_patch(patch)
  File "/data/safeuser/frappe/apps/frappe/frappe/modules/patch_handler.py", line 30, in run_patch
    if not run_single(patchmodule = patch):
  File "/data/safeuser/frappe/apps/frappe/frappe/modules/patch_handler.py", line 71, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/data/safeuser/frappe/apps/frappe/frappe/modules/patch_handler.py", line 91, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/data/safeuser/frappe/apps/erpnext/erpnext/patches/v12_0/retain_permission_rules_for_video_doctype.py", line 21, in execute
    doc.save()
  File "/data/safeuser/frappe/apps/frappe/frappe/model/document.py", line 273, in save
    return self._save(*args, **kwargs)
  File "/data/safeuser/frappe/apps/frappe/frappe/model/document.py", line 326, in _save
    self.run_post_save_methods()
  File "/data/safeuser/frappe/apps/frappe/frappe/model/document.py", line 924, in run_post_save_methods
    self.run_method("on_update")
  File "/data/safeuser/frappe/apps/frappe/frappe/model/document.py", line 794, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/data/safeuser/frappe/apps/frappe/frappe/model/document.py", line 1064, in composer
    return composed(self, method, *args, **kwargs)
  File "/data/safeuser/frappe/apps/frappe/frappe/model/document.py", line 1047, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/data/safeuser/frappe/apps/frappe/frappe/model/document.py", line 788, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/data/safeuser/frappe/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 300, in on_update
    self.run_module_method("on_doctype_update")
  File "/data/safeuser/frappe/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 369, in run_module_method
    module = load_doctype_module(self.name, self.module)
  File "/data/safeuser/frappe/apps/frappe/frappe/modules/utils.py", line 206, in load_doctype_module
    raise ImportError('Module import failed for {0} ({1})'.format(doctype, module_name + ' Error: ' + str(e)))
ImportError: Module import failed for Video (erpnext.education.doctype.video.video Error: No module named 'erpnext.education.doctype.video.video')

Additional information

LTS Ubuntu 18.04 erpnext 12.0.0-dev frappe 12.5.1 NOTE: Swapping frappe into developed gets worse "frappe.exceptions.DoesNotExistError: DocType Web Page Block not found"

Performed manual install several weeks ago and was properly working before of change of branch.

21234

I find that refactoring to be probably the source of the problem. fix: Move Video Doctype from Education module to Core (#21234)

AlvaroMolano commented 4 years ago

@nabinhait Closing by what reason?

nabinhait commented 4 years ago

ERPNext branch always depends on frappe branch, both should be in sync. The error is coming because you did not switch frappe branch to develop.