From 3083eb94fd3e4247f8c904fba1c46de82ca94677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Fern=C3=A1ndez=20=40PlanetaTIC?= Date: Fri, 16 Nov 2018 15:41:29 +0100 Subject: [PATCH 1/8] [12.0] [MIG] Disable modules installation --- auth_oauth_check_client_id/__manifest__.py | 2 +- auth_oauth_ip/__manifest__.py | 2 +- oauth_provider/__manifest__.py | 2 +- saas_base/__manifest__.py | 2 +- saas_client/__manifest__.py | 2 +- saas_portal/__manifest__.py | 2 +- saas_portal_backup/__manifest__.py | 2 +- saas_portal_demo/__manifest__.py | 2 +- saas_portal_portal/__manifest__.py | 2 +- saas_portal_sale/__manifest__.py | 1 + saas_portal_sale_online/__manifest__.py | 2 +- saas_portal_signup/__manifest__.py | 2 +- saas_portal_start/__manifest__.py | 2 +- saas_portal_tagging/__manifest__.py | 2 +- saas_portal_templates/__manifest__.py | 2 +- saas_server/__manifest__.py | 2 +- saas_server_autodelete/__manifest__.py | 2 +- saas_server_backup_ftp/__manifest__.py | 1 + saas_server_backup_rotate/__manifest__.py | 2 +- saas_server_backup_rotate_s3/__manifest__.py | 2 +- saas_server_backup_s3/__manifest__.py | 2 +- saas_server_demo/__manifest__.py | 2 +- saas_sysadmin/__manifest__.py | 2 +- saas_sysadmin_aws/__manifest__.py | 1 + saas_sysadmin_aws_route53/__manifest__.py | 2 +- saas_sysadmin_mailgun/__manifest__.py | 2 +- saas_sysadmin_route53/__manifest__.py | 2 +- saas_utils/__manifest__.py | 2 +- 28 files changed, 28 insertions(+), 25 deletions(-) diff --git a/auth_oauth_check_client_id/__manifest__.py b/auth_oauth_check_client_id/__manifest__.py index 00399d94d..d4c0811c0 100644 --- a/auth_oauth_check_client_id/__manifest__.py +++ b/auth_oauth_check_client_id/__manifest__.py @@ -9,5 +9,5 @@ 'depends': ['auth_oauth'], 'data': [], - 'installable': True, + 'installable': False, } diff --git a/auth_oauth_ip/__manifest__.py b/auth_oauth_ip/__manifest__.py index d1dea6b63..02d4524b2 100644 --- a/auth_oauth_ip/__manifest__.py +++ b/auth_oauth_ip/__manifest__.py @@ -26,6 +26,6 @@ "post_load": None, "pre_init_hook": None, "post_init_hook": None, - "installable": True, + "installable": False, "auto_install": False, } diff --git a/oauth_provider/__manifest__.py b/oauth_provider/__manifest__.py index 4fa877438..8c54c0221 100644 --- a/oauth_provider/__manifest__.py +++ b/oauth_provider/__manifest__.py @@ -14,5 +14,5 @@ 'data': [ 'security/ir.model.access.csv', ], - 'installable': True, + 'installable': False, } diff --git a/saas_base/__manifest__.py b/saas_base/__manifest__.py index b68318cc5..d48d00c70 100644 --- a/saas_base/__manifest__.py +++ b/saas_base/__manifest__.py @@ -8,5 +8,5 @@ 'website': 'https://it-projects.info', 'depends': ['saas_utils'], 'data': [], - 'installable': True, + 'installable': False, } diff --git a/saas_client/__manifest__.py b/saas_client/__manifest__.py index 4b145fbf9..8e71db3b2 100644 --- a/saas_client/__manifest__.py +++ b/saas_client/__manifest__.py @@ -25,7 +25,7 @@ 'data/ir_config_parameter.xml', 'data/ir_actions.xml', ], - 'installable': True, + 'installable': False, 'qweb': [ 'static/src/xml/saas_dashboard.xml', ], diff --git a/saas_portal/__manifest__.py b/saas_portal/__manifest__.py index 37e139e2c..3aba94def 100644 --- a/saas_portal/__manifest__.py +++ b/saas_portal/__manifest__.py @@ -26,5 +26,5 @@ 'data/res_users.xml', 'security/ir.model.access.csv', ], - 'installable': True, + 'installable': False, } diff --git a/saas_portal_backup/__manifest__.py b/saas_portal_backup/__manifest__.py index 6ab809206..639382347 100644 --- a/saas_portal_backup/__manifest__.py +++ b/saas_portal_backup/__manifest__.py @@ -9,5 +9,5 @@ 'data': [ 'views/saas_portal_views.xml', ], - 'installable': True, + 'installable': False, } diff --git a/saas_portal_demo/__manifest__.py b/saas_portal_demo/__manifest__.py index 24ed418fd..1a01bffa3 100644 --- a/saas_portal_demo/__manifest__.py +++ b/saas_portal_demo/__manifest__.py @@ -41,6 +41,6 @@ "post_load": None, "pre_init_hook": None, "post_init_hook": None, - "installable": True, + "installable": False, "auto_install": False, } diff --git a/saas_portal_portal/__manifest__.py b/saas_portal_portal/__manifest__.py index dcb35ec74..a5e5e8c6b 100644 --- a/saas_portal_portal/__manifest__.py +++ b/saas_portal_portal/__manifest__.py @@ -10,5 +10,5 @@ 'data': [ 'views/website_instance_templates.xml', ], - 'installable': True, + 'installable': False, } diff --git a/saas_portal_sale/__manifest__.py b/saas_portal_sale/__manifest__.py index ff5f82f54..7d14f0626 100644 --- a/saas_portal_sale/__manifest__.py +++ b/saas_portal_sale/__manifest__.py @@ -20,4 +20,5 @@ 'data/mail_template_data.xml', 'data/ir_config_parameter.xml', ], + 'installable': False, } diff --git a/saas_portal_sale_online/__manifest__.py b/saas_portal_sale_online/__manifest__.py index 102e8d214..e3db972d6 100644 --- a/saas_portal_sale_online/__manifest__.py +++ b/saas_portal_sale_online/__manifest__.py @@ -11,5 +11,5 @@ 'views/templates.xml', ], - 'installable': True, + 'installable': False, } diff --git a/saas_portal_signup/__manifest__.py b/saas_portal_signup/__manifest__.py index d47e10f87..4d8fd8902 100644 --- a/saas_portal_signup/__manifest__.py +++ b/saas_portal_signup/__manifest__.py @@ -8,7 +8,7 @@ 'website': 'https://it-projects.info', 'depends': ['auth_signup', 'saas_portal'], 'data': ['views/signup.xml'], - 'installable': True, + 'installable': False, 'description': ''' Module to book a new client in SaaS Portal from sign up diff --git a/saas_portal_start/__manifest__.py b/saas_portal_start/__manifest__.py index ad5d50bab..4a217b444 100644 --- a/saas_portal_start/__manifest__.py +++ b/saas_portal_start/__manifest__.py @@ -10,5 +10,5 @@ 'data': [ 'views/website.xml', ], - 'installable': True, + 'installable': False, } diff --git a/saas_portal_tagging/__manifest__.py b/saas_portal_tagging/__manifest__.py index 9ab72eddd..e69ae04ba 100644 --- a/saas_portal_tagging/__manifest__.py +++ b/saas_portal_tagging/__manifest__.py @@ -11,5 +11,5 @@ 'views/saas_portal_tagging_views.xml', 'views/wizard.xml' ], - 'installable': True, + 'installable': False, } diff --git a/saas_portal_templates/__manifest__.py b/saas_portal_templates/__manifest__.py index 81aab6a6c..db3f0e8f3 100644 --- a/saas_portal_templates/__manifest__.py +++ b/saas_portal_templates/__manifest__.py @@ -11,5 +11,5 @@ 'data': [ 'views/website.xml', ], - 'installable': True, + 'installable': False, } diff --git a/saas_server/__manifest__.py b/saas_server/__manifest__.py index f43487632..bfb7b223a 100644 --- a/saas_server/__manifest__.py +++ b/saas_server/__manifest__.py @@ -20,5 +20,5 @@ 'data/ir_config_parameter.xml', 'data/pre_install.yml', ], - 'installable': True, + 'installable': False, } diff --git a/saas_server_autodelete/__manifest__.py b/saas_server_autodelete/__manifest__.py index d28af8998..a33165443 100644 --- a/saas_server_autodelete/__manifest__.py +++ b/saas_server_autodelete/__manifest__.py @@ -10,5 +10,5 @@ 'data': [ 'data/ir_cron.xml', ], - 'installable': True, + 'installable': False, } diff --git a/saas_server_backup_ftp/__manifest__.py b/saas_server_backup_ftp/__manifest__.py index 98674ac3e..ae0ed882e 100644 --- a/saas_server_backup_ftp/__manifest__.py +++ b/saas_server_backup_ftp/__manifest__.py @@ -12,4 +12,5 @@ 'views/res_config.xml', 'data/ir_cron.xml', ], + 'installable': False, } diff --git a/saas_server_backup_rotate/__manifest__.py b/saas_server_backup_rotate/__manifest__.py index a55cf74ae..8bec0666b 100644 --- a/saas_server_backup_rotate/__manifest__.py +++ b/saas_server_backup_rotate/__manifest__.py @@ -11,5 +11,5 @@ 'data/ir_cron.xml', 'views/res_config.xml', ], - 'installable': True, + 'installable': False, } diff --git a/saas_server_backup_rotate_s3/__manifest__.py b/saas_server_backup_rotate_s3/__manifest__.py index bdd2151d9..2186dd313 100644 --- a/saas_server_backup_rotate_s3/__manifest__.py +++ b/saas_server_backup_rotate_s3/__manifest__.py @@ -10,5 +10,5 @@ "external_dependencies": {"python": ['boto', 'rotate_backups_s3'], "bin": []}, 'data': [ ], - 'installable': True, + 'installable': False, } diff --git a/saas_server_backup_s3/__manifest__.py b/saas_server_backup_s3/__manifest__.py index 8ec22e136..f39b427a1 100644 --- a/saas_server_backup_s3/__manifest__.py +++ b/saas_server_backup_s3/__manifest__.py @@ -15,5 +15,5 @@ 'data': [ 'views/res_config.xml', ], - 'installable': True, + 'installable': False, } diff --git a/saas_server_demo/__manifest__.py b/saas_server_demo/__manifest__.py index 4cc6a02ee..ddf9e9e80 100644 --- a/saas_server_demo/__manifest__.py +++ b/saas_server_demo/__manifest__.py @@ -26,6 +26,6 @@ "post_load": None, "pre_init_hook": None, "post_init_hook": None, - "installable": True, + "installable": False, "auto_install": False, } diff --git a/saas_sysadmin/__manifest__.py b/saas_sysadmin/__manifest__.py index ccf8660f8..d6ff5d75f 100644 --- a/saas_sysadmin/__manifest__.py +++ b/saas_sysadmin/__manifest__.py @@ -11,5 +11,5 @@ 'data': [ 'views/saas_portal_views.xml', ], - 'installable': True, + 'installable': False, } diff --git a/saas_sysadmin_aws/__manifest__.py b/saas_sysadmin_aws/__manifest__.py index 41510b61e..c7b0550b9 100644 --- a/saas_sysadmin_aws/__manifest__.py +++ b/saas_sysadmin_aws/__manifest__.py @@ -10,4 +10,5 @@ 'data': [ 'views/res_config.xml', ], + 'installable': False, } diff --git a/saas_sysadmin_aws_route53/__manifest__.py b/saas_sysadmin_aws_route53/__manifest__.py index 6e82c2ec6..30569d887 100644 --- a/saas_sysadmin_aws_route53/__manifest__.py +++ b/saas_sysadmin_aws_route53/__manifest__.py @@ -22,6 +22,6 @@ ], "demo": [ ], - "installable": True, + "installable": False, "auto_install": False, } diff --git a/saas_sysadmin_mailgun/__manifest__.py b/saas_sysadmin_mailgun/__manifest__.py index 340ffd394..5301bfc29 100644 --- a/saas_sysadmin_mailgun/__manifest__.py +++ b/saas_sysadmin_mailgun/__manifest__.py @@ -21,6 +21,6 @@ ], "demo": [ ], - "installable": True, + "installable": False, "auto_install": False, } diff --git a/saas_sysadmin_route53/__manifest__.py b/saas_sysadmin_route53/__manifest__.py index 8d24dc33a..93775ebd6 100644 --- a/saas_sysadmin_route53/__manifest__.py +++ b/saas_sysadmin_route53/__manifest__.py @@ -18,5 +18,5 @@ ], 'data': [ ], - 'installable': True, + 'installable': False, } diff --git a/saas_utils/__manifest__.py b/saas_utils/__manifest__.py index ca9d01d80..aeba64028 100644 --- a/saas_utils/__manifest__.py +++ b/saas_utils/__manifest__.py @@ -28,5 +28,5 @@ 'website': 'http://www.openjaf.com', 'category': 'Base', 'depends': ['base'], - 'installable': True + 'installable': False } From 7de6ffdb9391d1b99c52f1464f8d2a6abae3ed19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Fern=C3=A1ndez=20=40PlanetaTIC?= Date: Wed, 28 Nov 2018 12:52:02 +0100 Subject: [PATCH 2/8] [12.0] [MIG] auth_oauth_check_client_id --- auth_oauth_check_client_id/__manifest__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auth_oauth_check_client_id/__manifest__.py b/auth_oauth_check_client_id/__manifest__.py index d4c0811c0..201f93e8b 100644 --- a/auth_oauth_check_client_id/__manifest__.py +++ b/auth_oauth_check_client_id/__manifest__.py @@ -1,6 +1,6 @@ { 'name': 'auth_oauth - check client_id', - 'version': '11.0.1.0.0', + 'version': '12.0.1.0.0', 'author': 'Ivan Yelizariev, Nicolas JEUDY', 'license': 'LGPL-3', 'category': 'SaaS', @@ -9,5 +9,5 @@ 'depends': ['auth_oauth'], 'data': [], - 'installable': False, + 'installable': True, } From 854ce7aedea57d52ebda4c9728e815528a66e83e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Fern=C3=A1ndez=20=40PlanetaTIC?= Date: Thu, 13 Dec 2018 17:48:53 +0100 Subject: [PATCH 3/8] [12.0] [MIG] auth_oauth_ip --- auth_oauth_ip/__manifest__.py | 4 ++-- auth_oauth_ip/models.py | 15 ++++----------- auth_oauth_ip/views.xml | 32 +++++++++++++++----------------- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/auth_oauth_ip/__manifest__.py b/auth_oauth_ip/__manifest__.py index 02d4524b2..30317b7ab 100644 --- a/auth_oauth_ip/__manifest__.py +++ b/auth_oauth_ip/__manifest__.py @@ -3,7 +3,7 @@ "summary": """Allows to check access_token by requests in local network""", "category": "Extra Tools", "images": [], - "version": "11.0.1.0.0", + "version": "12.0.1.0.0", "author": "IT-Projects LLC, Ivan Yelizariev, Nicolas JEUDY", "support": "apps@it-projects.info", "website": "https://it-projects.info", @@ -26,6 +26,6 @@ "post_load": None, "pre_init_hook": None, "post_init_hook": None, - "installable": False, + "installable": True, "auto_install": False, } diff --git a/auth_oauth_ip/models.py b/auth_oauth_ip/models.py index a70a7bea8..7cec7d90f 100644 --- a/auth_oauth_ip/models.py +++ b/auth_oauth_ip/models.py @@ -23,6 +23,8 @@ class res_users(models.Model): _inherit = 'res.users' def _auth_oauth_rpc(self, endpoint, access_token, local_host=None, local_port=None): + local_host = local_host or self.env.context.get('local_host') + local_port = local_port or self.env.context.get('local_port') params = werkzeug.url_encode({'access_token': access_token}) host = None try: @@ -39,7 +41,6 @@ def _auth_oauth_rpc(self, endpoint, access_token, local_host=None, local_port=No else: url = endpoint + '?' + params req = urllib.request.Request(url, headers={'host': host}) - print(('url', url)) with urllib.request.urlopen(req) as response: html = response.read() @@ -47,14 +48,6 @@ def _auth_oauth_rpc(self, endpoint, access_token, local_host=None, local_port=No @api.model def _auth_oauth_validate(self, provider, access_token): - """ return the validation data corresponding to the access token """ p = self.env['auth.oauth.provider'].browse(provider) - validation = self._auth_oauth_rpc( - p.validation_endpoint, access_token, local_host=p.local_host, local_port=p.local_port) - if validation.get("error"): - raise Exception(validation['error']) - if p.data_endpoint: - data = self._auth_oauth_rpc( - p.data_endpoint, access_token, local_host=p.local_host, local_port=p.local_port) - validation.update(data) - return validation + self = self.with_context(local_host=p.local_host, local_port=p.local_port) + return super(res_users, self)._auth_oauth_validate(provider, access_token) diff --git a/auth_oauth_ip/views.xml b/auth_oauth_ip/views.xml index 9d06f95bc..79e03325e 100644 --- a/auth_oauth_ip/views.xml +++ b/auth_oauth_ip/views.xml @@ -1,18 +1,16 @@ - - - - auth.oauth.provider.form - auth.oauth.provider - - - - - - - - - - - - + + + auth.oauth.provider.form + auth.oauth.provider + + + + + + + + + + + From c56187fc9ca7a271e1a1d1d82d93d85325b87c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Fern=C3=A1ndez=20=40PlanetaTIC?= Date: Thu, 13 Dec 2018 17:49:44 +0100 Subject: [PATCH 4/8] [12.0] [MIG] saas_base --- saas_base/__manifest__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/saas_base/__manifest__.py b/saas_base/__manifest__.py index d48d00c70..441d75194 100644 --- a/saas_base/__manifest__.py +++ b/saas_base/__manifest__.py @@ -1,12 +1,12 @@ { 'name': 'SaaS Base', - 'version': '11.0.1.0.1', + 'version': '12.0.1.0.1', 'author': 'Cesar Lage, Nicolas JEUDY', 'license': 'LGPL-3', 'category': 'SaaS', "support": "apps@it-projects.info", 'website': 'https://it-projects.info', - 'depends': ['saas_utils'], + 'depends': [], 'data': [], - 'installable': False, + 'installable': True, } From d70487da0785d2c3775d9c3697dc948ed5527cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Fern=C3=A1ndez=20=40PlanetaTIC?= Date: Thu, 13 Dec 2018 17:50:39 +0100 Subject: [PATCH 5/8] [12.0] [MIG] saas_server --- saas_server/__init__.py | 2 + saas_server/__manifest__.py | 8 +-- saas_server/controllers/main.py | 72 +----------------------- saas_server/data/auth_oauth_data.xml | 4 +- saas_server/data/ir_config_parameter.xml | 12 +--- saas_server/data/pre_install.xml | 6 ++ saas_server/data/pre_install.yml | 8 --- saas_server/models/__init__.py | 1 + saas_server/models/res_users.py | 20 +++++++ saas_server/models/saas_server.py | 14 ++--- saas_server/security/ir.model.access.csv | 2 + 11 files changed, 47 insertions(+), 102 deletions(-) create mode 100644 saas_server/data/pre_install.xml delete mode 100644 saas_server/data/pre_install.yml create mode 100644 saas_server/models/res_users.py create mode 100644 saas_server/security/ir.model.access.csv diff --git a/saas_server/__init__.py b/saas_server/__init__.py index 91c5580fe..68f53272a 100644 --- a/saas_server/__init__.py +++ b/saas_server/__init__.py @@ -1,2 +1,4 @@ +ADMINUSER_ID = 2 + from . import controllers from . import models diff --git a/saas_server/__manifest__.py b/saas_server/__manifest__.py index bfb7b223a..5b0315c96 100644 --- a/saas_server/__manifest__.py +++ b/saas_server/__manifest__.py @@ -1,6 +1,6 @@ { 'name': 'SaaS Server', - 'version': '11.0.1.0.0', + 'version': '12.0.1.0.0', 'author': 'Ivan Yelizariev, Nicolas JEUDY', 'license': 'LGPL-3', 'category': 'SaaS', @@ -10,7 +10,6 @@ 'auth_oauth', 'auth_oauth_ip', 'saas_base', - 'saas_utils', 'website', ], 'data': [ @@ -18,7 +17,8 @@ 'views/res_config_settings_views.xml', 'data/auth_oauth_data.xml', 'data/ir_config_parameter.xml', - 'data/pre_install.yml', + 'data/pre_install.xml', + 'security/ir.model.access.csv', ], - 'installable': False, + 'installable': True, } diff --git a/saas_server/controllers/main.py b/saas_server/controllers/main.py index ca9c8c637..4535f703a 100644 --- a/saas_server/controllers/main.py +++ b/saas_server/controllers/main.py @@ -143,7 +143,7 @@ def upgrade_database(self, **post): @fragment_to_query_string @webservice def rename_database(self, **post): - _logger.info('delete_database post: %s', post) + _logger.info('rename_database post: %s', post) state = simplejson.loads(post.get('state')) client_id = state.get('client_id') new_dbname = state.get('new_dbname') @@ -197,65 +197,6 @@ def delete_database(self, **post): # return werkzeug.utils.redirect('/auth_oauth/signin?%s' % werkzeug.url_encode(params)) return werkzeug.utils.redirect('/web') - @http.route(['/saas_server/ab/css/.css'], type='http', auth='public') - def ab_css(self, dbuuid=None): - content = '' - message = self._get_message(dbuuid) - if message: - content = ''' -.odoo .announcement_bar{ - display:block; -} - -.announcement_bar>span.message:before{ - content: %s -} - -.announcement_bar>.url>a:before{ - content: 'Contact Us' -} - -.announcement_bar .close { - height: 15px; - width: 15px; - background : url(/web/static/src/img/icons/fa-close.png) no-repeat; - background-size : 15px 15px; - opacity: 1; -} - -.announcement_bar { - color: # ffffff; - height: 30px; - vertical-align: middle !important; - text-align: center !important; - width: 100%; - - border: 0 !important; - margin: 0 !important; - padding: 8px !important; - - background-color: # 8785C0; - background-image: -webkit-linear-gradient(135deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0) 25%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.05) 50%, rgba(255, 255, 255, 0.05) 75%, rgba(255, 255, 255, 0) 75%, rgba(255, 255, 255, 0) 100% ); - background-size: 40px 40px; - -webkit-transition: all 350ms ease; - text-shadow: 0px 0px 2px rgba(0,0,0,0.2); - box-shadow: 0px 2px 10px rgba(0,0,0,0.38) inset; - display: none; -} - -.announcement_bar a { - font-weight: bold; - color: # d3ffb0 !important; - text-decoration: none !important; - border-radius: 3px; - padding: 5px 8px; - cursor: pointer; - -webkit-transition: all 350ms ease; -} - ''' - content = content.replace('%s', message) - return http.Response(content, mimetype='text/css') - @http.route(['/saas_server/sync_server'], type='http', auth='public') @webservice def stats(self, **post): @@ -288,17 +229,6 @@ def stats(self, **post): }) return simplejson.dumps(res) - def _get_message(self, dbuuid): - message = False - domain = [('client_id', '=', dbuuid)] - client = request.env['saas_server.client'].sudo().search(domain) - if client: - diff = datetime.datetime.strptime(client.expiration_datetime, DEFAULT_SERVER_DATETIME_FORMAT) - datetime.datetime.now() - hours_remaining = diff.seconds / 3600 + 1 - plural = hours_remaining > 1 and 's' or '' - message = _("'You use a live preview. The database will be destroyed after %s hour%s.'") % (str(hours_remaining), plural) - return message - @http.route(['/saas_server/backup_database'], type='http', website=True, auth='public') @fragment_to_query_string def backup_database(self, **post): diff --git a/saas_server/data/auth_oauth_data.xml b/saas_server/data/auth_oauth_data.xml index a2d83b360..73ffa4bf5 100644 --- a/saas_server/data/auth_oauth_data.xml +++ b/saas_server/data/auth_oauth_data.xml @@ -1,5 +1,5 @@ - + SaaS @@ -17,4 +17,4 @@ - + diff --git a/saas_server/data/ir_config_parameter.xml b/saas_server/data/ir_config_parameter.xml index fc9f1d3fb..ebc831598 100644 --- a/saas_server/data/ir_config_parameter.xml +++ b/saas_server/data/ir_config_parameter.xml @@ -1,17 +1,9 @@ - + - - saas_client.ab_location - http://odoo.local/saas_server/ab/css/%s.css - - - saas_client.ab_register - https://www.it-projects.info/page/website.contactus/? - saas_client.saas_dashboard http://odoo.local/my/home - + diff --git a/saas_server/data/pre_install.xml b/saas_server/data/pre_install.xml new file mode 100644 index 000000000..7899c3014 --- /dev/null +++ b/saas_server/data/pre_install.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/saas_server/data/pre_install.yml b/saas_server/data/pre_install.yml deleted file mode 100644 index 8af28d9c7..000000000 --- a/saas_server/data/pre_install.yml +++ /dev/null @@ -1,8 +0,0 @@ -- - !python {model: res.users}: | - SUPERUSER_ID = 1 - oauth_provider_id = ref('saas_server.saas_oauth_provider') - self.browse(SUPERUSER_ID).write({'oauth_provider_id': oauth_provider_id, 'oauth_uid': SUPERUSER_ID}) - - dbuuid = self.env['ir.config_parameter'].sudo().get_param('database.uuid') - self.env['auth.oauth.provider'].browse(oauth_provider_id).write({'client_id': dbuuid}) diff --git a/saas_server/models/__init__.py b/saas_server/models/__init__.py index d7aad6cf4..5c00140ec 100644 --- a/saas_server/models/__init__.py +++ b/saas_server/models/__init__.py @@ -1,2 +1,3 @@ from . import saas_server from . import res_config_settings +from . import res_users diff --git a/saas_server/models/res_users.py b/saas_server/models/res_users.py new file mode 100644 index 000000000..2624f669d --- /dev/null +++ b/saas_server/models/res_users.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 PlanetaTIC +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo import api, models, SUPERUSER_ID +from .. import ADMINUSER_ID + + +class Users(models.Model): + _inherit = 'res.users' + + @api.model + def _saas_server_config_oauth(self): + oauth_provider = self.env.ref('saas_server.saas_oauth_provider') + self.browse(ADMINUSER_ID).write({ + 'oauth_provider_id': oauth_provider.id, + 'oauth_uid': SUPERUSER_ID}) + + dbuuid = self.env['ir.config_parameter'].get_param('database.uuid') + oauth_provider.write({'client_id': dbuuid}) diff --git a/saas_server/models/saas_server.py b/saas_server/models/saas_server.py index 1ac9d7e87..a0eec7d91 100644 --- a/saas_server/models/saas_server.py +++ b/saas_server/models/saas_server.py @@ -9,6 +9,7 @@ from odoo.tools.translate import _ from odoo.addons.saas_base.tools import get_size from odoo import api, models, fields, SUPERUSER_ID, exceptions +from .. import ADMINUSER_ID from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT import logging @@ -117,9 +118,7 @@ def prepare_database(self, **kwargs): @api.model def _config_parameters_to_copy(self): - return ['saas_client.ab_location', - 'saas_client.ab_register', - 'saas_client.saas_dashboard'] + return ['saas_client.saas_dashboard'] @api.multi def _prepare_database(self, @@ -185,7 +184,7 @@ def _prepare_database(self, 'email': 'onwer-email@example.com', }) - client_env['res.users'].browse(SUPERUSER_ID).write({ + client_env['res.users'].browse(ADMINUSER_ID).write({ 'oauth_provider_id': oauth_provider.id, 'oauth_uid': SUPERUSER_ID, 'oauth_access_token': access_token @@ -205,7 +204,7 @@ def _prepare_database(self, # user already exists (e.g. administrator) user = res[0] if not user: - user = client_env['res.users'].browse(SUPERUSER_ID) + user = client_env['res.users'].browse(ADMINUSER_ID) vals = owner_user vals.update({ @@ -251,7 +250,8 @@ def _get_data(self, client_env, check_client_id): if check_client_id != client_id: return {'state': 'deleted'} users = client_env['res.users'].search( - [('share', '=', False), ('id', '!=', SUPERUSER_ID)]) + [('share', '=', False), + ('id', 'not in', (SUPERUSER_ID, ADMINUSER_ID))]) param_obj = client_env['ir.config_parameter'] max_users = param_obj.sudo().get_param( 'saas_client.max_users', '0').strip() @@ -366,7 +366,7 @@ def _upgrade_database(self, client_env, data): continue users = [] for u in g.users: - if u.id != SUPERUSER_ID: + if u.id not in (SUPERUSER_ID, ADMINUSER_ID): users.append((3, u.id, 0)) g.write({'users': users}) diff --git a/saas_server/security/ir.model.access.csv b/saas_server/security/ir.model.access.csv new file mode 100644 index 000000000..99219acf9 --- /dev/null +++ b/saas_server/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_saas_client,saas_server.client,model_saas_server_client,base.group_system,1,1,1,0 From d3bacee4484770c00426e46f17c68071573b297e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Fern=C3=A1ndez=20=40PlanetaTIC?= Date: Thu, 13 Dec 2018 17:51:23 +0100 Subject: [PATCH 6/8] [12.0] [MIG] saas_client --- saas_client/__init__.py | 3 ++ saas_client/__manifest__.py | 6 +-- saas_client/controllers/main.py | 1 + .../controllers/web_settings_dashboard.py | 3 +- saas_client/data/auth_oauth_data.xml | 4 +- saas_client/data/ir_actions.xml | 24 +++++------ saas_client/data/ir_config_parameter.xml | 4 +- saas_client/data/ir_cron.xml | 16 ++++--- saas_client/http.py | 3 +- saas_client/models/res_config.py | 21 ++++------ saas_client/models/res_user.py | 7 ++-- saas_client/models/update.py | 1 - saas_client/security/groups.xml | 18 ++++---- saas_client/security/rules.xml | 4 +- saas_client/static/src/js/saas_client.js | 30 ------------- saas_client/static/src/xml/saas_dashboard.xml | 4 +- saas_client/translate.py | 34 +++++++++++++++ saas_client/views/res_config.xml | 42 +++++++++---------- saas_client/views/saas_client.xml | 18 ++++---- 19 files changed, 117 insertions(+), 126 deletions(-) create mode 100644 saas_client/translate.py diff --git a/saas_client/__init__.py b/saas_client/__init__.py index 26fafcba6..7973e0a14 100644 --- a/saas_client/__init__.py +++ b/saas_client/__init__.py @@ -1,3 +1,6 @@ +ADMINUSER_ID = 2 + from . import controllers from . import models from . import http +from . import translate diff --git a/saas_client/__manifest__.py b/saas_client/__manifest__.py index 8e71db3b2..b53c86409 100644 --- a/saas_client/__manifest__.py +++ b/saas_client/__manifest__.py @@ -1,6 +1,6 @@ { 'name': 'SaaS Client', - 'version': '11.0.1.0.0', + 'version': '12.0.1.0.0', 'author': 'Ivan Yelizariev, Nicolas JEUDY', 'license': 'LGPL-3', 'category': 'SaaS', @@ -10,7 +10,7 @@ 'auth_oauth', 'auth_oauth_ip', 'auth_oauth_check_client_id', - 'saas_utils', + 'saas_base', 'mail', 'web_settings_dashboard', 'access_limit_records_number', @@ -25,7 +25,7 @@ 'data/ir_config_parameter.xml', 'data/ir_actions.xml', ], - 'installable': False, + 'installable': True, 'qweb': [ 'static/src/xml/saas_dashboard.xml', ], diff --git a/saas_client/controllers/main.py b/saas_client/controllers/main.py index 35530cf93..992753b73 100644 --- a/saas_client/controllers/main.py +++ b/saas_client/controllers/main.py @@ -28,5 +28,6 @@ def web_login(self, redirect=None, **kw): suspended = param_model.sudo().get_param('saas_client.suspended', '0') page_for_suspended = param_model.sudo().get_param('saas_client.page_for_suspended', '/') if suspended == '1': + request.params['login_success'] = False return werkzeug.utils.redirect(page_for_suspended, 303) return super(SaaSClientLogin, self).web_login(redirect, **kw) diff --git a/saas_client/controllers/web_settings_dashboard.py b/saas_client/controllers/web_settings_dashboard.py index dc147821f..f0a25c62d 100644 --- a/saas_client/controllers/web_settings_dashboard.py +++ b/saas_client/controllers/web_settings_dashboard.py @@ -1,5 +1,6 @@ import odoo from odoo import http, SUPERUSER_ID +from .. import ADMINUSER_ID from odoo.http import request from odoo.addons.web_settings_dashboard.controllers.main import WebSettingsDashboard from odoo.addons.saas_base.tools import get_size @@ -18,7 +19,7 @@ def web_settings_dashboard_data(self, **kw): uid = request.session.uid user_obj = request.env['res.users'].sudo().browse(uid) - cur_users = request.env['res.users'].search_count([('share', '=', False), ('id', '!=', SUPERUSER_ID)]) + cur_users = request.env['res.users'].search_count([('share', '=', False), ('id', 'not in', (SUPERUSER_ID, ADMINUSER_ID))]) max_users = request.env['ir.config_parameter'].sudo().get_param('saas_client.max_users', default='') expiration_datetime = request.env['ir.config_parameter'].sudo().get_param('saas_client.expiration_datetime', default='').strip() datetime_obj = expiration_datetime and datetime.strptime(expiration_datetime, DEFAULT_SERVER_DATETIME_FORMAT) diff --git a/saas_client/data/auth_oauth_data.xml b/saas_client/data/auth_oauth_data.xml index 2bbd60778..36bfd12db 100644 --- a/saas_client/data/auth_oauth_data.xml +++ b/saas_client/data/auth_oauth_data.xml @@ -1,5 +1,5 @@ - + SaaS @@ -17,4 +17,4 @@ - + diff --git a/saas_client/data/ir_actions.xml b/saas_client/data/ir_actions.xml index 0f0718e8f..fb07e8cda 100644 --- a/saas_client/data/ir_actions.xml +++ b/saas_client/data/ir_actions.xml @@ -1,18 +1,17 @@ - - + - - SaaS Run Remaining Action Todo - True - ir.actions.server - - code - + + SaaS Run Remaining Action Todo + True + ir.actions.server + + code + action = {} if uid and self.pool('res.users').browse(cr, uid, uid, context=context).has_group('base.group_system'): todos = self._next_action(cr, uid) or {} @@ -20,7 +19,6 @@ if uid and self.pool('res.users').browse(cr, uid, uid, context=context).has_grou if config.get('type') not in ('ir.actions.act_window_close',): action = config action = action or self.pool['ir.model.data'].xmlid_to_object(cr, 1, 'base.open_menu').action_launch(context=context) - - - - + + + diff --git a/saas_client/data/ir_config_parameter.xml b/saas_client/data/ir_config_parameter.xml index 8b0c0b096..dc138f449 100644 --- a/saas_client/data/ir_config_parameter.xml +++ b/saas_client/data/ir_config_parameter.xml @@ -1,5 +1,5 @@ - + saas_client.pay_subscription_url @@ -10,4 +10,4 @@ / - + diff --git a/saas_client/data/ir_cron.xml b/saas_client/data/ir_cron.xml index 30bb85bb1..2dfdcbc86 100644 --- a/saas_client/data/ir_cron.xml +++ b/saas_client/data/ir_cron.xml @@ -1,10 +1,8 @@ - - - - days - -1 - - - - + + + days + -1 + + + diff --git a/saas_client/http.py b/saas_client/http.py index 952040afe..729727d29 100644 --- a/saas_client/http.py +++ b/saas_client/http.py @@ -1,4 +1,5 @@ import odoo +from . import ADMINUSER_ID from odoo.http import OpenERPSession from odoo.addons.base_sparse_field.models.fields import monkey_patch from odoo.addons.saas_base.exceptions import SuspendedDBException @@ -10,7 +11,7 @@ def check_security(self): uid = self.uid env = odoo.api.Environment(cr, uid, {}) suspended = env['ir.config_parameter'].sudo().get_param('saas_client.suspended', '0') - if suspended == "1" and uid != odoo.SUPERUSER_ID: + if suspended == "1" and uid not in (odoo.SUPERUSER_ID, ADMINUSER_ID): raise SuspendedDBException return check_security.super(self) diff --git a/saas_client/models/res_config.py b/saas_client/models/res_config.py index 2ff5b0ded..5d0d5313a 100644 --- a/saas_client/models/res_config.py +++ b/saas_client/models/res_config.py @@ -1,23 +1,20 @@ from odoo import models, fields, api -class BaseConfigSettings(models.TransientModel): +class ResConfigSettings(models.TransientModel): _inherit = 'res.config.settings' - base_saas_domain = fields.Char('Base SaaS domain') - current_domain = fields.Char(readonly=True) domain_change_link = fields.Html(readonly=True) - # current_domain @api.model - def get_default_current_domain(self, fields): + def get_values(self): + res = super(ResConfigSettings, self).get_values() current_domain = self.env["ir.config_parameter"].sudo().get_param('web.base.url', default=None) - return {'current_domain': current_domain or False} - - # domain_change_link - @api.model - def get_default_domain_change_link(self, fields): link = self.env["ir.config_parameter"].sudo().get_param('saas_client.saas_dashboard', default=None) - html = link and '' + 'You can change your domain name here' + '' or False - return {'domain_change_link': html} + html = link and '' + 'You can change your domain name here' + '' or False + res.update( + current_domain=current_domain or False, + domain_change_link=html, + ) + return res diff --git a/saas_client/models/res_user.py b/saas_client/models/res_user.py index a83a76b44..aa301713b 100644 --- a/saas_client/models/res_user.py +++ b/saas_client/models/res_user.py @@ -1,4 +1,5 @@ -from odoo import SUPERUSER_ID as SI +from odoo import SUPERUSER_ID +from .. import ADMINUSER_ID from odoo import api from odoo import exceptions from odoo import models, fields @@ -17,7 +18,7 @@ def create(self, vals): max_users = self.env["ir.config_parameter"].sudo().get_param("saas_client.max_users") max_users = int(max_users) if max_users: - cur_users = self.env['res.users'].search_count([('share', '=', False), ('id', '!=', SI)]) + cur_users = self.env['res.users'].search_count([('share', '=', False), ('id', 'not in', (SUPERUSER_ID, ADMINUSER_ID))]) if cur_users >= max_users: raise exceptions.Warning(_('Maximum allowed users is %(max_users)s, while you already have %(cur_users)s') % {'max_users': max_users, 'cur_users': cur_users}) return super(ResUsers, self).create(vals) @@ -29,7 +30,7 @@ def check(cls, db, uid, passwd): try: self = api.Environment(cr, uid, {})[cls._name] suspended = self.env['ir.config_parameter'].sudo().get_param('saas_client.suspended', '0') - if suspended == "1" and uid != SI: + if suspended == "1" and uid not in (SUPERUSER_ID, ADMINUSER_ID): raise SuspendedDBException finally: cr.close() diff --git a/saas_client/models/update.py b/saas_client/models/update.py index ef6b6d5f3..ed5f4235d 100644 --- a/saas_client/models/update.py +++ b/saas_client/models/update.py @@ -7,7 +7,6 @@ class publisher_warranty_contract(AbstractModel): def update_notification(self, cron_mode=True): url = self.env['ir.config_parameter'].sudo().get_param('saas_client.publisher_warranty_url') - print(('update_notification', url)) if not url: return config.options["publisher_warranty_url"] = url diff --git a/saas_client/security/groups.xml b/saas_client/security/groups.xml index bc033b398..9ce675e6d 100644 --- a/saas_client/security/groups.xml +++ b/saas_client/security/groups.xml @@ -1,12 +1,8 @@ - - - - - SaaS Support - - Special group for superuser. Should not be used for client users - - - - + + + SaaS Support + + Special group for superuser. Should not be used for client users + + diff --git a/saas_client/security/rules.xml b/saas_client/security/rules.xml index 5c878501c..a6082eb75 100644 --- a/saas_client/security/rules.xml +++ b/saas_client/security/rules.xml @@ -1,5 +1,5 @@ - + - + diff --git a/saas_client/static/src/js/saas_client.js b/saas_client/static/src/js/saas_client.js index f6b37d3a7..e69de29bb 100644 --- a/saas_client/static/src/js/saas_client.js +++ b/saas_client/static/src/js/saas_client.js @@ -1,30 +0,0 @@ -odoo.saas_client = function(instance){ - var _t = instance.web._t, - _lt = instance.web._lt; - - instance.web.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); - return _.str.sprintf(this._ab_location_value, dbuuid); - }, - show_annoucement_bar: function(){ - var self = this; - var config_parameter = new instance.web.Model('ir.config_parameter'); - var _super = self._super; - return config_parameter.call('search_read', [[['key', 'in', ['saas_client.ab_location', 'saas_client.ab_register']]], ['key', 'value']]).then(function(res) { - _.each(res, function(r){ - if (r.key === 'saas_client.ab_location') { - self._ab_location_value = r.value; - } else if (r.key === 'saas_client.ab_register') { - self._ab_register_value = r.value; - } - }); - if (!self._ab_location_value) { - return; - } - _super.apply(self); - }); - } - }); -}; diff --git a/saas_client/static/src/xml/saas_dashboard.xml b/saas_client/static/src/xml/saas_dashboard.xml index eaaab9b7c..9841973e0 100644 --- a/saas_client/static/src/xml/saas_dashboard.xml +++ b/saas_client/static/src/xml/saas_dashboard.xml @@ -1,8 +1,8 @@ - -
+ +
diff --git a/saas_client/translate.py b/saas_client/translate.py new file mode 100644 index 000000000..14aea7796 --- /dev/null +++ b/saas_client/translate.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 PlanetaTIC +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo.addons.base_sparse_field.models.fields import monkey_patch +from odoo.tools.translate import GettextAlias + + +@monkey_patch(GettextAlias) +def _get_cr(self, frame, allow_create=True): + # try, in order: cr, cursor, self.env.cr, self.cr, + # request.env.cr + if 'cr' in frame.f_locals: + return frame.f_locals['cr'], False + if 'cursor' in frame.f_locals: + return frame.f_locals['cursor'], False + s = frame.f_locals.get('self') + if hasattr(s, 'env'): + return s.env.cr, False + if hasattr(s, 'cr'): + return s.cr, False + # Don't get cursor from request as its database can be different from the + # one in the thread! +# try: +# from odoo.http import request +# return request.env.cr, False +# except RuntimeError: +# pass + if allow_create: + # create a new cursor + db = self._get_db() + if db is not None: + return db.cursor(), True + return None, False diff --git a/saas_client/views/res_config.xml b/saas_client/views/res_config.xml index 76d73fd44..a6f6e4214 100644 --- a/saas_client/views/res_config.xml +++ b/saas_client/views/res_config.xml @@ -1,32 +1,28 @@ - - + General Settings res.config.settings - - -

Saas Tools

-
-
-
-
-
+ +

Saas Tools

+
+
+
+
+
+
+
- - + diff --git a/saas_client/views/saas_client.xml b/saas_client/views/saas_client.xml index a327d5237..2219f26f5 100644 --- a/saas_client/views/saas_client.xml +++ b/saas_client/views/saas_client.xml @@ -1,12 +1,8 @@ - - - - - + + + From 7f0404ff005155a1a81efadcb927a64d5b607fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Fern=C3=A1ndez=20=40PlanetaTIC?= Date: Thu, 13 Dec 2018 17:51:45 +0100 Subject: [PATCH 7/8] [12.0] [MIG] saas_server_backup_ftp --- saas_server_backup_ftp/__manifest__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/saas_server_backup_ftp/__manifest__.py b/saas_server_backup_ftp/__manifest__.py index ae0ed882e..b5d26bc4d 100644 --- a/saas_server_backup_ftp/__manifest__.py +++ b/saas_server_backup_ftp/__manifest__.py @@ -5,12 +5,12 @@ "support": "apps@it-projects.info", 'website': "https://twitter.com/nasyrov_ildar", 'category': 'SaaS', - 'version': '11.0.1.0.0', + 'version': '12.0.1.0.0', 'depends': ['saas_server'], "external_dependencies": {"python": ['pysftp'], "bin": []}, 'data': [ 'views/res_config.xml', 'data/ir_cron.xml', ], - 'installable': False, + 'installable': True, } From 06ef6751ea881ec4764a1cd033062d70dc9a6b67 Mon Sep 17 00:00:00 2001 From: Terence Nzaywa Date: Wed, 18 Mar 2020 04:08:26 +0300 Subject: [PATCH 8/8] [WIP] Porting of saas modules from v11 to v12 --- auth_oauth_check_client_id/__init__.py | 0 auth_oauth_check_client_id/__manifest__.py | 0 auth_oauth_check_client_id/models/__init__.py | 0 .../models/res_users.py | 0 .../static/description/icon.png | Bin auth_oauth_ip/README.rst | 0 auth_oauth_ip/__init__.py | 0 auth_oauth_ip/__manifest__.py | 0 auth_oauth_ip/doc/changelog.rst | 0 auth_oauth_ip/doc/index.rst | 0 auth_oauth_ip/models.py | 0 auth_oauth_ip/static/description/icon.png | Bin auth_oauth_ip/views.xml | 0 oauth_provider/__manifest__.py | 2 +- saas_base/__manifest__.py | 4 +- saas_client/__init__.py | 3 - saas_client/__manifest__.py | 5 +- .../controllers/web_settings_dashboard.py | 3 +- saas_client/data/auth_oauth_data.xml | 4 +- saas_client/data/ir_actions.xml | 24 +++--- saas_client/data/ir_config_parameter.xml | 4 +- saas_client/data/ir_cron.xml | 16 ++-- saas_client/http.py | 3 +- saas_client/models/res_user.py | 7 +- saas_client/models/update.py | 1 + saas_client/security/groups.xml | 18 ++-- saas_client/security/rules.xml | 4 +- saas_client/static/src/js/saas_client.js | 30 +++++++ saas_client/static/src/xml/saas_dashboard.xml | 4 +- saas_client/views/res_config.xml | 42 +++++----- saas_client/views/saas_client.xml | 18 ++-- saas_portal/__manifest__.py | 13 +-- saas_portal/models/saas_portal.py | 25 +++++- saas_portal/views/saas_portal.xml | 2 +- saas_portal_backup/__manifest__.py | 2 +- saas_portal_sale/__manifest__.py | 3 +- saas_portal_sale_online/__manifest__.py | 2 +- saas_portal_signup/__manifest__.py | 2 +- saas_portal_start/__manifest__.py | 4 +- saas_portal_tagging/__manifest__.py | 2 +- saas_portal_templates/__manifest__.py | 2 +- saas_server/__init__.py | 2 - saas_server/__manifest__.py | 5 +- saas_server/controllers/main.py | 79 +++++++++++++++++- saas_server/data/auth_oauth_data.xml | 4 +- saas_server/data/ir_config_parameter.xml | 12 ++- saas_server/data/pre_install.yml | 8 ++ saas_server/models/__init__.py | 1 - saas_server/models/saas_server.py | 14 ++-- saas_server_autodelete/__manifest__.py | 2 +- saas_server_backup_ftp/__manifest__.py | 3 +- saas_server_backup_rotate/__manifest__.py | 2 +- saas_server_backup_rotate_s3/__manifest__.py | 2 +- saas_server_backup_s3/__manifest__.py | 2 +- saas_server_demo/__manifest__.py | 2 +- saas_server_demo/models/module.py | 4 +- saas_sysadmin/__manifest__.py | 2 +- saas_sysadmin_aws/__manifest__.py | 1 - saas_sysadmin_aws_route53/__manifest__.py | 2 +- saas_sysadmin_mailgun/__manifest__.py | 2 +- saas_sysadmin_route53/__manifest__.py | 2 +- saas_utils/__manifest__.py | 2 +- 62 files changed, 273 insertions(+), 129 deletions(-) mode change 100644 => 100755 auth_oauth_check_client_id/__init__.py mode change 100644 => 100755 auth_oauth_check_client_id/__manifest__.py mode change 100644 => 100755 auth_oauth_check_client_id/models/__init__.py mode change 100644 => 100755 auth_oauth_check_client_id/models/res_users.py mode change 100644 => 100755 auth_oauth_check_client_id/static/description/icon.png mode change 100644 => 100755 auth_oauth_ip/README.rst mode change 100644 => 100755 auth_oauth_ip/__init__.py mode change 100644 => 100755 auth_oauth_ip/__manifest__.py mode change 100644 => 100755 auth_oauth_ip/doc/changelog.rst mode change 100644 => 100755 auth_oauth_ip/doc/index.rst mode change 100644 => 100755 auth_oauth_ip/models.py mode change 100644 => 100755 auth_oauth_ip/static/description/icon.png mode change 100644 => 100755 auth_oauth_ip/views.xml create mode 100644 saas_server/data/pre_install.yml diff --git a/auth_oauth_check_client_id/__init__.py b/auth_oauth_check_client_id/__init__.py old mode 100644 new mode 100755 diff --git a/auth_oauth_check_client_id/__manifest__.py b/auth_oauth_check_client_id/__manifest__.py old mode 100644 new mode 100755 diff --git a/auth_oauth_check_client_id/models/__init__.py b/auth_oauth_check_client_id/models/__init__.py old mode 100644 new mode 100755 diff --git a/auth_oauth_check_client_id/models/res_users.py b/auth_oauth_check_client_id/models/res_users.py old mode 100644 new mode 100755 diff --git a/auth_oauth_check_client_id/static/description/icon.png b/auth_oauth_check_client_id/static/description/icon.png old mode 100644 new mode 100755 diff --git a/auth_oauth_ip/README.rst b/auth_oauth_ip/README.rst old mode 100644 new mode 100755 diff --git a/auth_oauth_ip/__init__.py b/auth_oauth_ip/__init__.py old mode 100644 new mode 100755 diff --git a/auth_oauth_ip/__manifest__.py b/auth_oauth_ip/__manifest__.py old mode 100644 new mode 100755 diff --git a/auth_oauth_ip/doc/changelog.rst b/auth_oauth_ip/doc/changelog.rst old mode 100644 new mode 100755 diff --git a/auth_oauth_ip/doc/index.rst b/auth_oauth_ip/doc/index.rst old mode 100644 new mode 100755 diff --git a/auth_oauth_ip/models.py b/auth_oauth_ip/models.py old mode 100644 new mode 100755 diff --git a/auth_oauth_ip/static/description/icon.png b/auth_oauth_ip/static/description/icon.png old mode 100644 new mode 100755 diff --git a/auth_oauth_ip/views.xml b/auth_oauth_ip/views.xml old mode 100644 new mode 100755 diff --git a/oauth_provider/__manifest__.py b/oauth_provider/__manifest__.py index 8c54c0221..4fa877438 100644 --- a/oauth_provider/__manifest__.py +++ b/oauth_provider/__manifest__.py @@ -14,5 +14,5 @@ 'data': [ 'security/ir.model.access.csv', ], - 'installable': False, + 'installable': True, } diff --git a/saas_base/__manifest__.py b/saas_base/__manifest__.py index 441d75194..ee41be96b 100644 --- a/saas_base/__manifest__.py +++ b/saas_base/__manifest__.py @@ -1,12 +1,12 @@ { 'name': 'SaaS Base', - 'version': '12.0.1.0.1', + 'version': '11.0.1.0.1', 'author': 'Cesar Lage, Nicolas JEUDY', 'license': 'LGPL-3', 'category': 'SaaS', "support": "apps@it-projects.info", 'website': 'https://it-projects.info', - 'depends': [], + 'depends': ['base'], 'data': [], 'installable': True, } diff --git a/saas_client/__init__.py b/saas_client/__init__.py index 7973e0a14..26fafcba6 100644 --- a/saas_client/__init__.py +++ b/saas_client/__init__.py @@ -1,6 +1,3 @@ -ADMINUSER_ID = 2 - from . import controllers from . import models from . import http -from . import translate diff --git a/saas_client/__manifest__.py b/saas_client/__manifest__.py index b53c86409..1d3d37b05 100644 --- a/saas_client/__manifest__.py +++ b/saas_client/__manifest__.py @@ -1,6 +1,6 @@ { 'name': 'SaaS Client', - 'version': '12.0.1.0.0', + 'version': '11.0.1.0.0', 'author': 'Ivan Yelizariev, Nicolas JEUDY', 'license': 'LGPL-3', 'category': 'SaaS', @@ -10,14 +10,13 @@ 'auth_oauth', 'auth_oauth_ip', 'auth_oauth_check_client_id', - 'saas_base', 'mail', 'web_settings_dashboard', 'access_limit_records_number', ], 'data': [ 'views/saas_client.xml', - 'views/res_config.xml', + # 'views/res_config.xml', 'security/rules.xml', 'security/groups.xml', 'data/ir_cron.xml', diff --git a/saas_client/controllers/web_settings_dashboard.py b/saas_client/controllers/web_settings_dashboard.py index f0a25c62d..dc147821f 100644 --- a/saas_client/controllers/web_settings_dashboard.py +++ b/saas_client/controllers/web_settings_dashboard.py @@ -1,6 +1,5 @@ import odoo from odoo import http, SUPERUSER_ID -from .. import ADMINUSER_ID from odoo.http import request from odoo.addons.web_settings_dashboard.controllers.main import WebSettingsDashboard from odoo.addons.saas_base.tools import get_size @@ -19,7 +18,7 @@ def web_settings_dashboard_data(self, **kw): uid = request.session.uid user_obj = request.env['res.users'].sudo().browse(uid) - cur_users = request.env['res.users'].search_count([('share', '=', False), ('id', 'not in', (SUPERUSER_ID, ADMINUSER_ID))]) + cur_users = request.env['res.users'].search_count([('share', '=', False), ('id', '!=', SUPERUSER_ID)]) max_users = request.env['ir.config_parameter'].sudo().get_param('saas_client.max_users', default='') expiration_datetime = request.env['ir.config_parameter'].sudo().get_param('saas_client.expiration_datetime', default='').strip() datetime_obj = expiration_datetime and datetime.strptime(expiration_datetime, DEFAULT_SERVER_DATETIME_FORMAT) diff --git a/saas_client/data/auth_oauth_data.xml b/saas_client/data/auth_oauth_data.xml index 36bfd12db..2bbd60778 100644 --- a/saas_client/data/auth_oauth_data.xml +++ b/saas_client/data/auth_oauth_data.xml @@ -1,5 +1,5 @@ - + SaaS @@ -17,4 +17,4 @@ - + diff --git a/saas_client/data/ir_actions.xml b/saas_client/data/ir_actions.xml index fb07e8cda..0f0718e8f 100644 --- a/saas_client/data/ir_actions.xml +++ b/saas_client/data/ir_actions.xml @@ -1,17 +1,18 @@ - + + - - SaaS Run Remaining Action Todo - True - ir.actions.server - - code - + + SaaS Run Remaining Action Todo + True + ir.actions.server + + code + action = {} if uid and self.pool('res.users').browse(cr, uid, uid, context=context).has_group('base.group_system'): todos = self._next_action(cr, uid) or {} @@ -19,6 +20,7 @@ if uid and self.pool('res.users').browse(cr, uid, uid, context=context).has_grou if config.get('type') not in ('ir.actions.act_window_close',): action = config action = action or self.pool['ir.model.data'].xmlid_to_object(cr, 1, 'base.open_menu').action_launch(context=context) - - - + + + + diff --git a/saas_client/data/ir_config_parameter.xml b/saas_client/data/ir_config_parameter.xml index dc138f449..8b0c0b096 100644 --- a/saas_client/data/ir_config_parameter.xml +++ b/saas_client/data/ir_config_parameter.xml @@ -1,5 +1,5 @@ - + saas_client.pay_subscription_url @@ -10,4 +10,4 @@ / - + diff --git a/saas_client/data/ir_cron.xml b/saas_client/data/ir_cron.xml index 2dfdcbc86..30bb85bb1 100644 --- a/saas_client/data/ir_cron.xml +++ b/saas_client/data/ir_cron.xml @@ -1,8 +1,10 @@ - - - days - -1 - - - + + + + days + -1 + + + + diff --git a/saas_client/http.py b/saas_client/http.py index 729727d29..952040afe 100644 --- a/saas_client/http.py +++ b/saas_client/http.py @@ -1,5 +1,4 @@ import odoo -from . import ADMINUSER_ID from odoo.http import OpenERPSession from odoo.addons.base_sparse_field.models.fields import monkey_patch from odoo.addons.saas_base.exceptions import SuspendedDBException @@ -11,7 +10,7 @@ def check_security(self): uid = self.uid env = odoo.api.Environment(cr, uid, {}) suspended = env['ir.config_parameter'].sudo().get_param('saas_client.suspended', '0') - if suspended == "1" and uid not in (odoo.SUPERUSER_ID, ADMINUSER_ID): + if suspended == "1" and uid != odoo.SUPERUSER_ID: raise SuspendedDBException return check_security.super(self) diff --git a/saas_client/models/res_user.py b/saas_client/models/res_user.py index aa301713b..a83a76b44 100644 --- a/saas_client/models/res_user.py +++ b/saas_client/models/res_user.py @@ -1,5 +1,4 @@ -from odoo import SUPERUSER_ID -from .. import ADMINUSER_ID +from odoo import SUPERUSER_ID as SI from odoo import api from odoo import exceptions from odoo import models, fields @@ -18,7 +17,7 @@ def create(self, vals): max_users = self.env["ir.config_parameter"].sudo().get_param("saas_client.max_users") max_users = int(max_users) if max_users: - cur_users = self.env['res.users'].search_count([('share', '=', False), ('id', 'not in', (SUPERUSER_ID, ADMINUSER_ID))]) + cur_users = self.env['res.users'].search_count([('share', '=', False), ('id', '!=', SI)]) if cur_users >= max_users: raise exceptions.Warning(_('Maximum allowed users is %(max_users)s, while you already have %(cur_users)s') % {'max_users': max_users, 'cur_users': cur_users}) return super(ResUsers, self).create(vals) @@ -30,7 +29,7 @@ def check(cls, db, uid, passwd): try: self = api.Environment(cr, uid, {})[cls._name] suspended = self.env['ir.config_parameter'].sudo().get_param('saas_client.suspended', '0') - if suspended == "1" and uid not in (SUPERUSER_ID, ADMINUSER_ID): + if suspended == "1" and uid != SI: raise SuspendedDBException finally: cr.close() diff --git a/saas_client/models/update.py b/saas_client/models/update.py index ed5f4235d..ef6b6d5f3 100644 --- a/saas_client/models/update.py +++ b/saas_client/models/update.py @@ -7,6 +7,7 @@ class publisher_warranty_contract(AbstractModel): def update_notification(self, cron_mode=True): url = self.env['ir.config_parameter'].sudo().get_param('saas_client.publisher_warranty_url') + print(('update_notification', url)) if not url: return config.options["publisher_warranty_url"] = url diff --git a/saas_client/security/groups.xml b/saas_client/security/groups.xml index 9ce675e6d..bc033b398 100644 --- a/saas_client/security/groups.xml +++ b/saas_client/security/groups.xml @@ -1,8 +1,12 @@ - - - SaaS Support - - Special group for superuser. Should not be used for client users - - + + + + + SaaS Support + + Special group for superuser. Should not be used for client users + + + + diff --git a/saas_client/security/rules.xml b/saas_client/security/rules.xml index a6082eb75..5c878501c 100644 --- a/saas_client/security/rules.xml +++ b/saas_client/security/rules.xml @@ -1,5 +1,5 @@ - + - + diff --git a/saas_client/static/src/js/saas_client.js b/saas_client/static/src/js/saas_client.js index e69de29bb..f6b37d3a7 100644 --- a/saas_client/static/src/js/saas_client.js +++ b/saas_client/static/src/js/saas_client.js @@ -0,0 +1,30 @@ +odoo.saas_client = function(instance){ + var _t = instance.web._t, + _lt = instance.web._lt; + + instance.web.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); + return _.str.sprintf(this._ab_location_value, dbuuid); + }, + show_annoucement_bar: function(){ + var self = this; + var config_parameter = new instance.web.Model('ir.config_parameter'); + var _super = self._super; + return config_parameter.call('search_read', [[['key', 'in', ['saas_client.ab_location', 'saas_client.ab_register']]], ['key', 'value']]).then(function(res) { + _.each(res, function(r){ + if (r.key === 'saas_client.ab_location') { + self._ab_location_value = r.value; + } else if (r.key === 'saas_client.ab_register') { + self._ab_register_value = r.value; + } + }); + if (!self._ab_location_value) { + return; + } + _super.apply(self); + }); + } + }); +}; diff --git a/saas_client/static/src/xml/saas_dashboard.xml b/saas_client/static/src/xml/saas_dashboard.xml index 9841973e0..eaaab9b7c 100644 --- a/saas_client/static/src/xml/saas_dashboard.xml +++ b/saas_client/static/src/xml/saas_dashboard.xml @@ -1,8 +1,8 @@ - -
+ +
diff --git a/saas_client/views/res_config.xml b/saas_client/views/res_config.xml index a6f6e4214..75a1490a5 100644 --- a/saas_client/views/res_config.xml +++ b/saas_client/views/res_config.xml @@ -1,28 +1,32 @@ - + + General Settings res.config.settings - -

Saas Tools

-
-
-
-
-
- + + - + + diff --git a/saas_client/views/saas_client.xml b/saas_client/views/saas_client.xml index 2219f26f5..a327d5237 100644 --- a/saas_client/views/saas_client.xml +++ b/saas_client/views/saas_client.xml @@ -1,8 +1,12 @@ - - - + + + + + diff --git a/saas_portal/__manifest__.py b/saas_portal/__manifest__.py index 3aba94def..fa24d9589 100644 --- a/saas_portal/__manifest__.py +++ b/saas_portal/__manifest__.py @@ -6,11 +6,12 @@ 'category': 'SaaS', "support": "apps@it-projects.info", 'website': 'https://it-projects.info', - 'depends': ['oauth_provider', - 'website', - 'auth_signup', - 'saas_base', - 'saas_utils'], + 'depends': [ + 'oauth_provider', + 'website', + 'auth_signup', + 'saas_base', + ], 'data': [ 'data/mail_template_data.xml', 'data/plan_sequence.xml', @@ -26,5 +27,5 @@ 'data/res_users.xml', 'security/ir.model.access.csv', ], - 'installable': False, + 'installable': True, } diff --git a/saas_portal/models/saas_portal.py b/saas_portal/models/saas_portal.py index 00afb00af..f83b3b707 100644 --- a/saas_portal/models/saas_portal.py +++ b/saas_portal/models/saas_portal.py @@ -7,7 +7,7 @@ from odoo import api, exceptions, fields, models from odoo.tools import scan_languages from odoo.tools.translate import _ -from odoo.addons.base.res.res_partner import _tz_get +from odoo.addons.base.models.res_partner import _tz_get from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT from odoo.addons.saas_base.exceptions import MaximumTrialDBException @@ -74,11 +74,16 @@ def _request_params(self, path='/web', scheme=None, if not state: state = {} scheme = scheme or self.request_scheme + print ("scheme ", scheme) port = port or self.request_port + print ("port", port) scope = scope or ['userinfo', 'force_login', 'trial', 'skiptheuse'] + print ("scope 1 ", scope) scope = ' '.join(scope) + print ("scope 2", scope) client_id = client_id or self.env['oauth.application'].generate_client_id( ) + print ("client id ", client_id) params = { 'scope': scope, 'state': simplejson.dumps(state), @@ -86,6 +91,7 @@ def _request_params(self, path='/web', scheme=None, 'response_type': 'token', 'client_id': client_id, } + print ("paramas ______________", params) return params @api.multi @@ -99,10 +105,15 @@ def _request(self, **kwargs): def _request_server(self, path=None, scheme=None, port=None, **kwargs): self.ensure_one() scheme = scheme or self.local_request_scheme or self.request_scheme + print("scheme ", scheme) host = self.local_host or self.host + print ("host ", host) port = port or self.local_port or self.request_port + print ("port", port) params = self._request_params(**kwargs) + print ("params", params) access_token = self.oauth_application_id.sudo()._get_access_token(create=True) + print ("access_token", access_token) params.update({ 'token_type': 'Bearer', 'access_token': access_token, @@ -110,9 +121,13 @@ def _request_server(self, path=None, scheme=None, port=None, **kwargs): }) url = '{scheme}://{host}:{port}{path}'.format( scheme=scheme, host=host, port=port, path=path) + print ("url", url) req = requests.Request('GET', url, data=params, headers={'host': self.host}) + print ("req", req) req_kwargs = {'verify': self.verify_ssl} + print ("req_kwargs", req_kwargs) + print ("req.prepare() ", req.prepare()) return req.prepare(), req_kwargs @api.multi @@ -142,10 +157,12 @@ def action_sync_server(self, updating_client_ID=None): 'client_id': server.client_id, 'updating_client_ID': updating_client_ID, } - req, req_kwargs = server._request_server( - path='/saas_server/sync_server', state=state, client_id=server.client_id) + req, req_kwargs = server._request_server(path='/saas_server/sync_server', state=state, client_id=server.client_id) res = requests.Session().send(req, **req_kwargs) - + print ("state ", state) + print ("req", req) + print ("req_kwargs", req_kwargs); + print ("res ", res) if not res.ok: raise Warning(_('Reason: %s \n Message: %s') % (res.reason, res.content)) diff --git a/saas_portal/views/saas_portal.xml b/saas_portal/views/saas_portal.xml index 8630118ae..d1c7716f6 100644 --- a/saas_portal/views/saas_portal.xml +++ b/saas_portal/views/saas_portal.xml @@ -104,7 +104,7 @@ - + diff --git a/saas_portal_backup/__manifest__.py b/saas_portal_backup/__manifest__.py index 639382347..6ab809206 100644 --- a/saas_portal_backup/__manifest__.py +++ b/saas_portal_backup/__manifest__.py @@ -9,5 +9,5 @@ 'data': [ 'views/saas_portal_views.xml', ], - 'installable': False, + 'installable': True, } diff --git a/saas_portal_sale/__manifest__.py b/saas_portal_sale/__manifest__.py index 7d14f0626..8b80cede3 100644 --- a/saas_portal_sale/__manifest__.py +++ b/saas_portal_sale/__manifest__.py @@ -9,7 +9,7 @@ 'depends': [ 'sale', 'saas_portal', - 'product_price_factor', + # 'product_price_factor', 'saas_portal_start', 'contract', ], @@ -20,5 +20,4 @@ 'data/mail_template_data.xml', 'data/ir_config_parameter.xml', ], - 'installable': False, } diff --git a/saas_portal_sale_online/__manifest__.py b/saas_portal_sale_online/__manifest__.py index e3db972d6..102e8d214 100644 --- a/saas_portal_sale_online/__manifest__.py +++ b/saas_portal_sale_online/__manifest__.py @@ -11,5 +11,5 @@ 'views/templates.xml', ], - 'installable': False, + 'installable': True, } diff --git a/saas_portal_signup/__manifest__.py b/saas_portal_signup/__manifest__.py index 4d8fd8902..d47e10f87 100644 --- a/saas_portal_signup/__manifest__.py +++ b/saas_portal_signup/__manifest__.py @@ -8,7 +8,7 @@ 'website': 'https://it-projects.info', 'depends': ['auth_signup', 'saas_portal'], 'data': ['views/signup.xml'], - 'installable': False, + 'installable': True, 'description': ''' Module to book a new client in SaaS Portal from sign up diff --git a/saas_portal_start/__manifest__.py b/saas_portal_start/__manifest__.py index 4a217b444..6b29ac75f 100644 --- a/saas_portal_start/__manifest__.py +++ b/saas_portal_start/__manifest__.py @@ -8,7 +8,7 @@ 'website': 'https://it-projects.info', 'depends': ['website', 'saas_portal'], 'data': [ - 'views/website.xml', + # 'views/website.xml', ], - 'installable': False, + 'installable': True, } diff --git a/saas_portal_tagging/__manifest__.py b/saas_portal_tagging/__manifest__.py index e69ae04ba..9ab72eddd 100644 --- a/saas_portal_tagging/__manifest__.py +++ b/saas_portal_tagging/__manifest__.py @@ -11,5 +11,5 @@ 'views/saas_portal_tagging_views.xml', 'views/wizard.xml' ], - 'installable': False, + 'installable': True, } diff --git a/saas_portal_templates/__manifest__.py b/saas_portal_templates/__manifest__.py index db3f0e8f3..81aab6a6c 100644 --- a/saas_portal_templates/__manifest__.py +++ b/saas_portal_templates/__manifest__.py @@ -11,5 +11,5 @@ 'data': [ 'views/website.xml', ], - 'installable': False, + 'installable': True, } diff --git a/saas_server/__init__.py b/saas_server/__init__.py index 68f53272a..91c5580fe 100644 --- a/saas_server/__init__.py +++ b/saas_server/__init__.py @@ -1,4 +1,2 @@ -ADMINUSER_ID = 2 - from . import controllers from . import models diff --git a/saas_server/__manifest__.py b/saas_server/__manifest__.py index 5b0315c96..8a070564c 100644 --- a/saas_server/__manifest__.py +++ b/saas_server/__manifest__.py @@ -1,6 +1,6 @@ { 'name': 'SaaS Server', - 'version': '12.0.1.0.0', + 'version': '11.0.1.0.0', 'author': 'Ivan Yelizariev, Nicolas JEUDY', 'license': 'LGPL-3', 'category': 'SaaS', @@ -17,8 +17,7 @@ 'views/res_config_settings_views.xml', 'data/auth_oauth_data.xml', 'data/ir_config_parameter.xml', - 'data/pre_install.xml', - 'security/ir.model.access.csv', + # 'data/pre_install.yml', ], 'installable': True, } diff --git a/saas_server/controllers/main.py b/saas_server/controllers/main.py index 4535f703a..94f3cb40b 100644 --- a/saas_server/controllers/main.py +++ b/saas_server/controllers/main.py @@ -143,7 +143,7 @@ def upgrade_database(self, **post): @fragment_to_query_string @webservice def rename_database(self, **post): - _logger.info('rename_database post: %s', post) + _logger.info('delete_database post: %s', post) state = simplejson.loads(post.get('state')) client_id = state.get('client_id') new_dbname = state.get('new_dbname') @@ -197,17 +197,81 @@ def delete_database(self, **post): # return werkzeug.utils.redirect('/auth_oauth/signin?%s' % werkzeug.url_encode(params)) return werkzeug.utils.redirect('/web') + @http.route(['/saas_server/ab/css/.css'], type='http', auth='public') + def ab_css(self, dbuuid=None): + content = '' + message = self._get_message(dbuuid) + if message: + content = ''' +.odoo .announcement_bar{ + display:block; +} + +.announcement_bar>span.message:before{ + content: %s +} + +.announcement_bar>.url>a:before{ + content: 'Contact Us' +} + +.announcement_bar .close { + height: 15px; + width: 15px; + background : url(/web/static/src/img/icons/fa-close.png) no-repeat; + background-size : 15px 15px; + opacity: 1; +} + +.announcement_bar { + color: # ffffff; + height: 30px; + vertical-align: middle !important; + text-align: center !important; + width: 100%; + + border: 0 !important; + margin: 0 !important; + padding: 8px !important; + + background-color: # 8785C0; + background-image: -webkit-linear-gradient(135deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0) 25%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.05) 50%, rgba(255, 255, 255, 0.05) 75%, rgba(255, 255, 255, 0) 75%, rgba(255, 255, 255, 0) 100% ); + background-size: 40px 40px; + -webkit-transition: all 350ms ease; + text-shadow: 0px 0px 2px rgba(0,0,0,0.2); + box-shadow: 0px 2px 10px rgba(0,0,0,0.38) inset; + display: none; +} + +.announcement_bar a { + font-weight: bold; + color: # d3ffb0 !important; + text-decoration: none !important; + border-radius: 3px; + padding: 5px 8px; + cursor: pointer; + -webkit-transition: all 350ms ease; +} + ''' + content = content.replace('%s', message) + return http.Response(content, mimetype='text/css') + @http.route(['/saas_server/sync_server'], type='http', auth='public') @webservice def stats(self, **post): _logger.info('sync_server post: %s', post) state = simplejson.loads(post.get('state')) + print("state ", state) updating_client_ID = state.get('updating_client_ID') + print ("updating_client_ID ", updating_client_ID) access_token = post['access_token'] + print ("access_token ", access_token) saas_oauth_provider = request.env.ref('saas_server.saas_oauth_provider').sudo() + print ("saas_oauth_provider ", saas_oauth_provider) user_data = request.env['res.users'].sudo()._auth_oauth_rpc(saas_oauth_provider.validation_endpoint, access_token, local_host=saas_oauth_provider.local_host, local_port=saas_oauth_provider.local_port) + print ("user_data ", user_data) if user_data.get("error"): raise Exception(user_data['error']) @@ -227,8 +291,21 @@ def stats(self, **post): 'db_storage': client.db_storage, 'total_storage_limit': client.total_storage_limit, }) + print ("res ", res) + print ("simplejson.dumps(res) ",simplejson.dumps(res)) return simplejson.dumps(res) + def _get_message(self, dbuuid): + message = False + domain = [('client_id', '=', dbuuid)] + client = request.env['saas_server.client'].sudo().search(domain) + if client: + diff = datetime.datetime.strptime(client.expiration_datetime, DEFAULT_SERVER_DATETIME_FORMAT) - datetime.datetime.now() + hours_remaining = diff.seconds / 3600 + 1 + plural = hours_remaining > 1 and 's' or '' + message = _("'You use a live preview. The database will be destroyed after %s hour%s.'") % (str(hours_remaining), plural) + return message + @http.route(['/saas_server/backup_database'], type='http', website=True, auth='public') @fragment_to_query_string def backup_database(self, **post): diff --git a/saas_server/data/auth_oauth_data.xml b/saas_server/data/auth_oauth_data.xml index 73ffa4bf5..a2d83b360 100644 --- a/saas_server/data/auth_oauth_data.xml +++ b/saas_server/data/auth_oauth_data.xml @@ -1,5 +1,5 @@ - + SaaS @@ -17,4 +17,4 @@ - + diff --git a/saas_server/data/ir_config_parameter.xml b/saas_server/data/ir_config_parameter.xml index ebc831598..fc9f1d3fb 100644 --- a/saas_server/data/ir_config_parameter.xml +++ b/saas_server/data/ir_config_parameter.xml @@ -1,9 +1,17 @@ - + + + saas_client.ab_location + http://odoo.local/saas_server/ab/css/%s.css + + + saas_client.ab_register + https://www.it-projects.info/page/website.contactus/? + saas_client.saas_dashboard http://odoo.local/my/home - + diff --git a/saas_server/data/pre_install.yml b/saas_server/data/pre_install.yml new file mode 100644 index 000000000..8af28d9c7 --- /dev/null +++ b/saas_server/data/pre_install.yml @@ -0,0 +1,8 @@ +- + !python {model: res.users}: | + SUPERUSER_ID = 1 + oauth_provider_id = ref('saas_server.saas_oauth_provider') + self.browse(SUPERUSER_ID).write({'oauth_provider_id': oauth_provider_id, 'oauth_uid': SUPERUSER_ID}) + + dbuuid = self.env['ir.config_parameter'].sudo().get_param('database.uuid') + self.env['auth.oauth.provider'].browse(oauth_provider_id).write({'client_id': dbuuid}) diff --git a/saas_server/models/__init__.py b/saas_server/models/__init__.py index 5c00140ec..d7aad6cf4 100644 --- a/saas_server/models/__init__.py +++ b/saas_server/models/__init__.py @@ -1,3 +1,2 @@ from . import saas_server from . import res_config_settings -from . import res_users diff --git a/saas_server/models/saas_server.py b/saas_server/models/saas_server.py index a0eec7d91..1ac9d7e87 100644 --- a/saas_server/models/saas_server.py +++ b/saas_server/models/saas_server.py @@ -9,7 +9,6 @@ from odoo.tools.translate import _ from odoo.addons.saas_base.tools import get_size from odoo import api, models, fields, SUPERUSER_ID, exceptions -from .. import ADMINUSER_ID from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT import logging @@ -118,7 +117,9 @@ def prepare_database(self, **kwargs): @api.model def _config_parameters_to_copy(self): - return ['saas_client.saas_dashboard'] + return ['saas_client.ab_location', + 'saas_client.ab_register', + 'saas_client.saas_dashboard'] @api.multi def _prepare_database(self, @@ -184,7 +185,7 @@ def _prepare_database(self, 'email': 'onwer-email@example.com', }) - client_env['res.users'].browse(ADMINUSER_ID).write({ + client_env['res.users'].browse(SUPERUSER_ID).write({ 'oauth_provider_id': oauth_provider.id, 'oauth_uid': SUPERUSER_ID, 'oauth_access_token': access_token @@ -204,7 +205,7 @@ def _prepare_database(self, # user already exists (e.g. administrator) user = res[0] if not user: - user = client_env['res.users'].browse(ADMINUSER_ID) + user = client_env['res.users'].browse(SUPERUSER_ID) vals = owner_user vals.update({ @@ -250,8 +251,7 @@ def _get_data(self, client_env, check_client_id): if check_client_id != client_id: return {'state': 'deleted'} users = client_env['res.users'].search( - [('share', '=', False), - ('id', 'not in', (SUPERUSER_ID, ADMINUSER_ID))]) + [('share', '=', False), ('id', '!=', SUPERUSER_ID)]) param_obj = client_env['ir.config_parameter'] max_users = param_obj.sudo().get_param( 'saas_client.max_users', '0').strip() @@ -366,7 +366,7 @@ def _upgrade_database(self, client_env, data): continue users = [] for u in g.users: - if u.id not in (SUPERUSER_ID, ADMINUSER_ID): + if u.id != SUPERUSER_ID: users.append((3, u.id, 0)) g.write({'users': users}) diff --git a/saas_server_autodelete/__manifest__.py b/saas_server_autodelete/__manifest__.py index a33165443..d28af8998 100644 --- a/saas_server_autodelete/__manifest__.py +++ b/saas_server_autodelete/__manifest__.py @@ -10,5 +10,5 @@ 'data': [ 'data/ir_cron.xml', ], - 'installable': False, + 'installable': True, } diff --git a/saas_server_backup_ftp/__manifest__.py b/saas_server_backup_ftp/__manifest__.py index b5d26bc4d..98674ac3e 100644 --- a/saas_server_backup_ftp/__manifest__.py +++ b/saas_server_backup_ftp/__manifest__.py @@ -5,12 +5,11 @@ "support": "apps@it-projects.info", 'website': "https://twitter.com/nasyrov_ildar", 'category': 'SaaS', - 'version': '12.0.1.0.0', + 'version': '11.0.1.0.0', 'depends': ['saas_server'], "external_dependencies": {"python": ['pysftp'], "bin": []}, 'data': [ 'views/res_config.xml', 'data/ir_cron.xml', ], - 'installable': True, } diff --git a/saas_server_backup_rotate/__manifest__.py b/saas_server_backup_rotate/__manifest__.py index 8bec0666b..a55cf74ae 100644 --- a/saas_server_backup_rotate/__manifest__.py +++ b/saas_server_backup_rotate/__manifest__.py @@ -11,5 +11,5 @@ 'data/ir_cron.xml', 'views/res_config.xml', ], - 'installable': False, + 'installable': True, } diff --git a/saas_server_backup_rotate_s3/__manifest__.py b/saas_server_backup_rotate_s3/__manifest__.py index 2186dd313..bdd2151d9 100644 --- a/saas_server_backup_rotate_s3/__manifest__.py +++ b/saas_server_backup_rotate_s3/__manifest__.py @@ -10,5 +10,5 @@ "external_dependencies": {"python": ['boto', 'rotate_backups_s3'], "bin": []}, 'data': [ ], - 'installable': False, + 'installable': True, } diff --git a/saas_server_backup_s3/__manifest__.py b/saas_server_backup_s3/__manifest__.py index f39b427a1..8ec22e136 100644 --- a/saas_server_backup_s3/__manifest__.py +++ b/saas_server_backup_s3/__manifest__.py @@ -15,5 +15,5 @@ 'data': [ 'views/res_config.xml', ], - 'installable': False, + 'installable': True, } diff --git a/saas_server_demo/__manifest__.py b/saas_server_demo/__manifest__.py index ddf9e9e80..4cc6a02ee 100644 --- a/saas_server_demo/__manifest__.py +++ b/saas_server_demo/__manifest__.py @@ -26,6 +26,6 @@ "post_load": None, "pre_init_hook": None, "post_init_hook": None, - "installable": False, + "installable": True, "auto_install": False, } diff --git a/saas_server_demo/models/module.py b/saas_server_demo/models/module.py index bb8791c1b..cf3da68e2 100644 --- a/saas_server_demo/models/module.py +++ b/saas_server_demo/models/module.py @@ -1,7 +1,7 @@ import os from odoo import models, fields, api, tools -from odoo.addons.base.module.module import Module as A +from odoo.addons.base.models.ir_module import Module from odoo.modules import get_module_resource @@ -25,7 +25,7 @@ class ModuleDemo(models.Model): @staticmethod def get_values_from_terp(terp): - res = A.get_values_from_terp(terp) + res = Module.get_values_from_terp(terp) res.update({ 'demo_title': terp.get('demo_title', False), 'demo_summary': terp.get('demo_summary', False), diff --git a/saas_sysadmin/__manifest__.py b/saas_sysadmin/__manifest__.py index d6ff5d75f..ccf8660f8 100644 --- a/saas_sysadmin/__manifest__.py +++ b/saas_sysadmin/__manifest__.py @@ -11,5 +11,5 @@ 'data': [ 'views/saas_portal_views.xml', ], - 'installable': False, + 'installable': True, } diff --git a/saas_sysadmin_aws/__manifest__.py b/saas_sysadmin_aws/__manifest__.py index c7b0550b9..41510b61e 100644 --- a/saas_sysadmin_aws/__manifest__.py +++ b/saas_sysadmin_aws/__manifest__.py @@ -10,5 +10,4 @@ 'data': [ 'views/res_config.xml', ], - 'installable': False, } diff --git a/saas_sysadmin_aws_route53/__manifest__.py b/saas_sysadmin_aws_route53/__manifest__.py index 30569d887..6e82c2ec6 100644 --- a/saas_sysadmin_aws_route53/__manifest__.py +++ b/saas_sysadmin_aws_route53/__manifest__.py @@ -22,6 +22,6 @@ ], "demo": [ ], - "installable": False, + "installable": True, "auto_install": False, } diff --git a/saas_sysadmin_mailgun/__manifest__.py b/saas_sysadmin_mailgun/__manifest__.py index 5301bfc29..340ffd394 100644 --- a/saas_sysadmin_mailgun/__manifest__.py +++ b/saas_sysadmin_mailgun/__manifest__.py @@ -21,6 +21,6 @@ ], "demo": [ ], - "installable": False, + "installable": True, "auto_install": False, } diff --git a/saas_sysadmin_route53/__manifest__.py b/saas_sysadmin_route53/__manifest__.py index 93775ebd6..8d24dc33a 100644 --- a/saas_sysadmin_route53/__manifest__.py +++ b/saas_sysadmin_route53/__manifest__.py @@ -18,5 +18,5 @@ ], 'data': [ ], - 'installable': False, + 'installable': True, } diff --git a/saas_utils/__manifest__.py b/saas_utils/__manifest__.py index aeba64028..ca9d01d80 100644 --- a/saas_utils/__manifest__.py +++ b/saas_utils/__manifest__.py @@ -28,5 +28,5 @@ 'website': 'http://www.openjaf.com', 'category': 'Base', 'depends': ['base'], - 'installable': False + 'installable': True }