From 1476c907db3370f1fe0ab627f004a7be4237ff26 Mon Sep 17 00:00:00 2001 From: Bruce Date: Mon, 28 Nov 2016 15:24:18 +0700 Subject: [PATCH 1/3] fixed bug openerp define js --- saas_client/static/src/js/saas_client.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/saas_client/static/src/js/saas_client.js b/saas_client/static/src/js/saas_client.js index b22f536e4..2d2961a19 100644 --- a/saas_client/static/src/js/saas_client.js +++ b/saas_client/static/src/js/saas_client.js @@ -1,8 +1,9 @@ -openerp.saas_client = function(instance){ - var _t = instance.web._t, - _lt = instance.web._lt; +odoo.define('saas_client', function (require) { - instance.web.WebClient.include({ + var WebClient = require('web.WebClient'); + + + WebClient.include({ _ab_location: function(dbuuid) { var ab_register = _.str.sprintf('%s/%s', this._ab_register_value, dbuuid); $('#announcement_bar_table').find('.url a').attr('href', ab_register); @@ -26,4 +27,4 @@ openerp.saas_client = function(instance){ }); } }); -}; \ No newline at end of file +}); \ No newline at end of file From e75d8eb85f7763c005a1ea2f9b157e8f05376a3d Mon Sep 17 00:00:00 2001 From: Bruce Date: Mon, 28 Nov 2016 16:00:08 +0700 Subject: [PATCH 2/3] when we're create new client, auto copy filestore data --- saas_server/models/saas_server.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/saas_server/models/saas_server.py b/saas_server/models/saas_server.py index 608f78f25..30f5663e2 100644 --- a/saas_server/models/saas_server.py +++ b/saas_server/models/saas_server.py @@ -6,11 +6,14 @@ from odoo.service import db from odoo import api, models, fields, SUPERUSER_ID, exceptions from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT +from odoo.tools import config + import psycopg2 import random import string - +from distutils.dir_util import copy_tree import logging + _logger = logging.getLogger(__name__) @@ -41,6 +44,12 @@ class SaasServerClient(models.Model): def create_database(self, template_db=None, demo=False, lang='en_US'): self.ensure_one() new_db = self.name + path_file_store = config.filestore(template_db) + parent_paths = path_file_store.split(template_db) + if len(parent_paths) > 1: + parent_path = parent_paths[0] + new_db_filstore_path = parent_path + new_db + copy_tree(path_file_store, new_db_filstore_path) res = {} if template_db: odoo.service.db._drop_conn(self.env.cr, template_db) From baff96930dea2a1deb5636bc397b0d1e2e7b4ba5 Mon Sep 17 00:00:00 2001 From: Bruce Date: Thu, 1 Dec 2016 15:59:31 +0700 Subject: [PATCH 3/3] try copy filestore --- saas_server/models/saas_server.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/saas_server/models/saas_server.py b/saas_server/models/saas_server.py index 30f5663e2..fbdf3ece3 100644 --- a/saas_server/models/saas_server.py +++ b/saas_server/models/saas_server.py @@ -44,12 +44,15 @@ class SaasServerClient(models.Model): def create_database(self, template_db=None, demo=False, lang='en_US'): self.ensure_one() new_db = self.name - path_file_store = config.filestore(template_db) - parent_paths = path_file_store.split(template_db) - if len(parent_paths) > 1: - parent_path = parent_paths[0] - new_db_filstore_path = parent_path + new_db - copy_tree(path_file_store, new_db_filstore_path) + try: + path_file_store = config.filestore(template_db) + parent_paths = path_file_store.split(template_db) + if len(parent_paths) > 1: + parent_path = parent_paths[0] + new_db_filstore_path = parent_path + new_db + copy_tree(path_file_store, new_db_filstore_path) + except Exception, ex: + _logger.error(ex) res = {} if template_db: odoo.service.db._drop_conn(self.env.cr, template_db)