Browse Source

[IMP] odoo module installation

Gogs 6 years ago
parent
commit
5ba1393b76
3 changed files with 16 additions and 5 deletions
  1. 6 1
      api/resources/odoo_resource.py
  2. 2 2
      api/utils/docker_api.py
  3. 8 2
      api/utils/odoo_api.py

+ 6 - 1
api/resources/odoo_resource.py

@@ -277,11 +277,16 @@ class OdooResource(Resource):
         if 'error' in result:
             err['error_message'] = result['error']
 
+        if len(err) != 0:    
+            return self.create_response(request, err)
+        
         return self.create_response(request, {
-            'result': ''
+            'success_message': '%s successfully installed' % data.get('module')
         })
 
         
 
         
 
+        
+

+ 2 - 2
api/utils/docker_api.py

@@ -143,7 +143,7 @@ def run_container(image=None, name=None, ports=[], volumes=None, net=None):
 
 '''
 '''
-def start_container(id=None):
+def start_container(id_or_name=None):
     if not id:
         return None
 
@@ -173,7 +173,7 @@ def start_container(id=None):
 
 '''
 '''
-def restart_container(id=None):
+def restart_container(id_or_name=None):
     if not id:
         return None
 

+ 8 - 2
api/utils/odoo_api.py

@@ -234,12 +234,18 @@ def install_module(system_name=None, module_name=None):
         execute(['rm', '-Rf', module_path])
 
     # 4. clone repo
-    cloned = clone_repo(module_name, os.path.join(system_path, 'custom/addons'))
+    cloned = clone_repo(module_name, os.path.join(system_path, 'custom-addons'))
 
     if not cloned:
         return {'error': 'cannot clone repo'}
 
-    # 5. start system container
+    # 5. remove git data
+    git_data_path = os.path.join(module_name, '.git')
+
+    if os.path.exists(git_data_path):
+        execute(['rm', '-Rf', git_data_path])
+
+    # 6. start system container
     started = start_container(system_name)
 
     if not started: