Skip to content

Commit de26cf9

Browse files
committed
[FIX] server: prevent crash if an addon folder is not found
1 parent 967b66b commit de26cf9

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

server/core/odoo.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,13 @@ def build_base(self, ls, used_config):
230230
self.process_rebuilds(ls)
231231
addonsSymbol = self.symbols.get_symbol(["odoo", 'addons'])
232232
if Odoo.import_odoo_addons:
233-
addonsSymbol.paths += [
234-
os.path.join(self.odooPath, "addons"),
235-
#"/home/odoo/Documents/odoo-servers/test_odoo/enterprise",
233+
if os.path.exists(os.path.join(self.odooPath, "addons")):
234+
addonsSymbol.paths += [
235+
os.path.join(self.odooPath, "addons")
236236
]
237+
else:
238+
ls.show_message_log("Odoo addons not found at " + os.path.join(self.odooPath, "addons"), MessageType.Error)
239+
return False
237240
addonsSymbol.paths += used_config.addons
238241
return True
239242
else:
@@ -365,12 +368,13 @@ def build_modules(self, ls):
365368
addonsSymbol = self.symbols.get_symbol(["odoo", "addons"])
366369
addonsPaths = self.symbols.get_symbol(["odoo", "addons"]).paths
367370
for path in addonsPaths:
368-
dirs = os.listdir(path)
369-
for dir in dirs:
370-
if os.path.isdir(os.path.join(path, dir)):
371-
PythonArchBuilder(ls, addonsSymbol, os.path.join(path, dir)).load_arch(require_module=True)
372-
if self.stop_init:
373-
break
371+
if os.path.exists(path):
372+
dirs = os.listdir(path)
373+
for dir in dirs:
374+
if os.path.isdir(os.path.join(path, dir)):
375+
PythonArchBuilder(ls, addonsSymbol, os.path.join(path, dir)).load_arch(require_module=True)
376+
if self.stop_init:
377+
break
374378
if self.stop_init:
375379
return
376380
#needed?

0 commit comments

Comments
 (0)