From 80b96aa9d1f99569e66ca74ae35e54e9eb64379d Mon Sep 17 00:00:00 2001 From: Ildar Nasyrov Date: Mon, 23 Jul 2018 06:47:51 +0000 Subject: [PATCH 1/5] :ambulance: saas_portal_signup: separate Odoo saas server needs server name in full db-name (--db-filter=^%h$ configuration) --- saas_portal_signup/controllers/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/saas_portal_signup/controllers/main.py b/saas_portal_signup/controllers/main.py index 2460b3b40..c3f6aac92 100644 --- a/saas_portal_signup/controllers/main.py +++ b/saas_portal_signup/controllers/main.py @@ -45,7 +45,9 @@ def do_signup(self, qcontext): if qcontext.get('country_id', False): values['country_id'] = qcontext['country_id'] if qcontext.get('dbname', False): - f_dbname = '%s.%s' % (qcontext['dbname'], self.get_saas_domain()) + Plan = request.env['saas_portal.plan'].sudo() + plan = Plan.browse(qcontext['plan_id']) + f_dbname = '%s.%s' % (qcontext['dbname'], plan.server_id.name) full_dbname = f_dbname.replace('www.', '') db_exists = odoo.service.db.exp_db_exist(full_dbname) assert re.match('[a-zA-Z0-9_.-]+$', qcontext.get('dbname') From 9a8534020bf5d7bc1ddc124afae0daae9fb15546 Mon Sep 17 00:00:00 2001 From: Ildar Nasyrov Date: Mon, 23 Jul 2018 07:06:21 +0000 Subject: [PATCH 2/5] :ambulance: saas_portal_signup: odoo.exceptions.AccessError: ("Database fetch misses ids (('1',)) and has extra ids ((1,)), may be caused by a type incoherence in a previous request", None) --- saas_portal_signup/controllers/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/saas_portal_signup/controllers/main.py b/saas_portal_signup/controllers/main.py index c3f6aac92..f18692e43 100644 --- a/saas_portal_signup/controllers/main.py +++ b/saas_portal_signup/controllers/main.py @@ -46,8 +46,8 @@ def do_signup(self, qcontext): values['country_id'] = qcontext['country_id'] if qcontext.get('dbname', False): Plan = request.env['saas_portal.plan'].sudo() - plan = Plan.browse(qcontext['plan_id']) - f_dbname = '%s.%s' % (qcontext['dbname'], plan.server_id.name) + plan = Plan.browse(int(qcontext['plan_id'])) + f_dbname = '%s.%s' % (qcontext['dbname'], plan.server_id.local_host) full_dbname = f_dbname.replace('www.', '') db_exists = odoo.service.db.exp_db_exist(full_dbname) assert re.match('[a-zA-Z0-9_.-]+$', qcontext.get('dbname') From 57f10d2e94d3d4654a45f9222aec722990e4185a Mon Sep 17 00:00:00 2001 From: Ildar Nasyrov Date: Mon, 23 Jul 2018 07:17:57 +0000 Subject: [PATCH 3/5] :ambulance: saas_portal_signup: SaaS Server on separate Odoo server --- saas_portal_signup/controllers/main.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/saas_portal_signup/controllers/main.py b/saas_portal_signup/controllers/main.py index f18692e43..4aba8a870 100644 --- a/saas_portal_signup/controllers/main.py +++ b/saas_portal_signup/controllers/main.py @@ -29,13 +29,19 @@ def get_auth_signup_qcontext(self): if not qcontext.get('countries', False): qcontext['countries'] = request.env['res.country'].search([]) if not qcontext.get('base_saas_domain', False): - qcontext['base_saas_domain'] = self.get_saas_domain() + qcontext['base_saas_domain'] = self.get_saas_domain(qcontext.get('plan_id')) return qcontext - def get_saas_domain(self): - config = request.env['ir.config_parameter'] - full_param = 'saas_portal.base_saas_domain' - base_saas_domain = config.sudo().get_param(full_param) + def get_saas_domain(self, plan_id): + # config = request.env['ir.config_parameter'] + # full_param = 'saas_portal.base_saas_domain' + # base_saas_domain = config.sudo().get_param(full_param) + if plan_id: + Plan = request.env['saas_portal.plan'].sudo() + plan = Plan.browse(int(plan_id)) + base_saas_domain = plan.server_id.local_host + else: + base_saas_domain = 'select plan' return base_saas_domain def do_signup(self, qcontext): @@ -45,9 +51,7 @@ def do_signup(self, qcontext): if qcontext.get('country_id', False): values['country_id'] = qcontext['country_id'] if qcontext.get('dbname', False): - Plan = request.env['saas_portal.plan'].sudo() - plan = Plan.browse(int(qcontext['plan_id'])) - f_dbname = '%s.%s' % (qcontext['dbname'], plan.server_id.local_host) + f_dbname = '%s.%s' % (qcontext['dbname'], self.get_saas_domain(qcontext['plan_id']) full_dbname = f_dbname.replace('www.', '') db_exists = odoo.service.db.exp_db_exist(full_dbname) assert re.match('[a-zA-Z0-9_.-]+$', qcontext.get('dbname') From 077ed9c458617e848ee14547006a38a2982141f8 Mon Sep 17 00:00:00 2001 From: Ildar Nasyrov Date: Mon, 23 Jul 2018 07:20:24 +0000 Subject: [PATCH 4/5] :ambulance: saas_portal_signup: invalid syntax --- saas_portal_signup/controllers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/saas_portal_signup/controllers/main.py b/saas_portal_signup/controllers/main.py index 4aba8a870..71a69f914 100644 --- a/saas_portal_signup/controllers/main.py +++ b/saas_portal_signup/controllers/main.py @@ -51,7 +51,7 @@ def do_signup(self, qcontext): if qcontext.get('country_id', False): values['country_id'] = qcontext['country_id'] if qcontext.get('dbname', False): - f_dbname = '%s.%s' % (qcontext['dbname'], self.get_saas_domain(qcontext['plan_id']) + f_dbname = '%s.%s' % (qcontext['dbname'], self.get_saas_domain(qcontext['plan_id'])) full_dbname = f_dbname.replace('www.', '') db_exists = odoo.service.db.exp_db_exist(full_dbname) assert re.match('[a-zA-Z0-9_.-]+$', qcontext.get('dbname') From d09f2c2dcc9a5bc377dd771513a54eb39bd8d9b8 Mon Sep 17 00:00:00 2001 From: Ildar Nasyrov Date: Mon, 23 Jul 2018 07:37:41 +0000 Subject: [PATCH 5/5] :ambulance: saas_portal, saas_portal_signup: full db name depends on the selected plan --- saas_portal/controllers/main.py | 11 +++++++---- saas_portal_signup/controllers/main.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/saas_portal/controllers/main.py b/saas_portal/controllers/main.py index 9ef86e432..945daced4 100644 --- a/saas_portal/controllers/main.py +++ b/saas_portal/controllers/main.py @@ -34,7 +34,7 @@ def add_new_client(self, redirect_to_signup=False, **post): query = {'redirect': redirect} return http.local_redirect(path=url, query=query) - dbname = self.get_full_dbname(post.get('dbname')) + dbname = self.get_full_dbname(post.get('dbname'), post.get('plan_id')) user_id = request.session.uid partner_id = None if user_id: @@ -78,10 +78,13 @@ def get_config_parameter(self, param): full_param = 'saas_portal.%s' % param return config.sudo().get_param(full_param) - def get_full_dbname(self, dbname): - if not dbname: + def get_full_dbname(self, dbname, plan_id): + if not dbname or not plan_id: return None - full_dbname = '%s.%s' % (dbname, self.get_config_parameter('base_saas_domain')) + Plan = request.env['saas_portal.plan'].sudo() + plan = Plan.browse(int(plan_id)) + base_saas_domain = plan.server_id.local_host + full_dbname = '%s.%s' % (dbname, base_saas_domain) return full_dbname.replace('www.', '') def get_plan(self, plan_id=None): diff --git a/saas_portal_signup/controllers/main.py b/saas_portal_signup/controllers/main.py index 71a69f914..52457fee4 100644 --- a/saas_portal_signup/controllers/main.py +++ b/saas_portal_signup/controllers/main.py @@ -41,7 +41,7 @@ def get_saas_domain(self, plan_id): plan = Plan.browse(int(plan_id)) base_saas_domain = plan.server_id.local_host else: - base_saas_domain = 'select plan' + base_saas_domain = 'depends on the plan' return base_saas_domain def do_signup(self, qcontext):