ERPNext Conference 2019* ERPNext.com Blog

Error adding new Module Def


#1

Hey guys,
So I am trying to add a new Doctype and a new Module Def.

The error appearing is this:

ImportError: No module named hotel_transportation

I am running on:

ERPNext: v12.1.5 (version-12)

Frappe Framework: v12.0.10 (version-12)

Any idea what’s this about ?


#2

LATE EDIT for Traceback error

[ERROR] 2019-10-09 09:14:36,489 | /home/frappe/frappe-bench/apps/frappe/frappe/app.py:
Site: WEBSITE RETRACTED
Form Dict: {
 "action": "Save",
 "cmd": "frappe.desk.form.save.savedocs",
 "doc": "{\"docstatus\":0,\"doctype\":\"Module Def\",\"name\":\"New Module Def 1\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"module_name\":\"Hotel trans$
}
Request Error
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
    response = frappe.api.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 56, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1036, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 22, in savedocs
    doc.save()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 271, in save
    return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 294, in _save
    self.insert()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 258, in insert
    self.run_post_save_methods()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 917, in run_post_save_methods
    self.run_method("on_update")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 786, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1056, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1039, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 780, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/module_def/module_def.py", line 15, in on_update
    self.create_modules_folder()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/module_def/module_def.py", line 20, in create_modules_folder
    module_path = frappe.get_app_path(self.app_name, self.name)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 831, in get_app_path
    return get_pymodule_path(app_name, *joins)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 846, in get_pymodule_path
    return os.path.join(os.path.dirname(get_module(scrub(modulename)).__file__), *joins)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 808, in get_module
    return importlib.import_module(modulename)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named hotel_transportation

#3

In your database, table Module Def check if there is an entry by the same name. If yes, delete that row.


#4

How is it possible to have such a row if this is a brand new Module Def to be added ? haha :slight_smile:


#5

You were adding Hotel Transportation as a new module def ?


#6

Yes indeed, a brand new Doctype with a brand new Module Def…


#7

What did you set in the field app ?


#8

Same name as the module def …


#9

any chance you created the app but forgot to install it on the site ?


#10

No chance because I don’t know how to do that by myself haha but I will double check maybe somehow I did that accidentally … it’s a good point :slight_smile: