diff --git a/app_saas/__manifest__.py b/app_saas/__manifest__.py index 18c951be..910646b5 100644 --- a/app_saas/__manifest__.py +++ b/app_saas/__manifest__.py @@ -25,8 +25,8 @@ ############################################################################## { - 'name': 'odooapp.cn SaaS Client.Odoo中文应用商店SaaS云服务客户端', - 'version': '18.0.24.11.08', + 'name': 'odooapp.cn SaaS Client-Ai Passport.Odoo中文应用商店SaaS云服务客户端', + 'version': '18.0.24.12.06', 'author': 'odooai.cn', 'category': 'Base', 'website': 'https://www.odooai.cn', @@ -37,24 +37,31 @@ 'currency': 'EUR', 'images': ['static/description/banner.png'], 'summary': ''' - Odoo中文云服务客户端,模块持续更新中。 + AiSaas云服务,使用Ai通行证,一键实现全社交媒体统一登录SSO。 + 支持微信、抖音、QQ、淘宝、钉钉、支付宝、企业微信、Facebook、Google、微软Azure等整合登录。 + 在Odoo中获取最新的中文翻译(另行收费),获取当前Odoo模块最新版本更新等。 支持Odoo中文版在线更新及 www.odooapp.cn 的信息推送等。 安装即代表同意我司云服务用户协议及隐私政策。 https://www.odooapp.cn/conditions ''', 'description': ''' - 1. 快速访问Odoo中文应用商店并获取独享Odoo中文通行码 - 2. 一键获取最新应用信息,最新行业服务包 - 3. 一键获取Odoo中文翻译更新 - 4. 快速获取Odoo服务,Odoo升级评估 + 1. Ai通行证实现全社交媒体登录支持 + 2. 快速访问Odoo中文应用商店并获取独享Odoo中文通行码,可随时断开云服务连接 + 3. 一键获取最新Odoo中文应用模块与主题,最新行业服务包 + 4. 一键获取Odoo中文翻译更新(收费) + 5. 快速获取Odoo服务,Odoo升级评估 + 6. 系统出错时一键提交,获取技术支持(会员专属) 11.多语言支持,多公司支持 - 12.仅从Odoo18企业版,社区版版本开始支持 + 12.仅从Odoo18-16企业版,社区版版本开始支持 13.代码完全开源 ''', 'depends': [ 'app_common', + 'auth_oauth', # 'website', ], 'data': [ + 'data/auth_oauth_data.xml', + 'views/auth_oauth_provider_views.xml', 'views/res_config_settings_views.xml', ], 'assets': { @@ -66,8 +73,6 @@ ], }, 'demo': [ - # 'data/model_new_demo.xml', - # 'views/website_templates.xml', ], # 'pre_init_hook': 'pre_init_hook', # 'post_init_hook': 'post_init_hook', diff --git a/app_saas/data/auth_oauth_data.xml b/app_saas/data/auth_oauth_data.xml new file mode 100644 index 00000000..47e82663 --- /dev/null +++ b/app_saas/data/auth_oauth_data.xml @@ -0,0 +1,24 @@ + + + + + Ai Passport of odooapp.cn + Ai通行证-Odoo中文应用商店 + https://www.odooapp.cn/oauth/authorize + https://www.odooapp.cn/oauth/token + odoo,profile + https://www.odooapp.cn/oauth/profile + + + fa fa-2x fa-fw fa-sign-in text-primary + + + + + + + + + diff --git a/app_saas/models/__init__.py b/app_saas/models/__init__.py index ce7ed9e5..94facece 100644 --- a/app_saas/models/__init__.py +++ b/app_saas/models/__init__.py @@ -2,3 +2,7 @@ # Part of odooAi.cn. See LICENSE file for full copyright and licensing details. from . import res_config_settings +from . import auth_oauth_provider +from . import res_users + + diff --git a/app_saas/models/auth_oauth_provider.py b/app_saas/models/auth_oauth_provider.py new file mode 100644 index 00000000..2b9ba53b --- /dev/null +++ b/app_saas/models/auth_oauth_provider.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from odoo import api, fields, models, modules, tools, _ + +import base64 +from datetime import timedelta + +class AuthOAuthProvider(models.Model): + + _inherit = 'auth.oauth.provider' + _order = 'sequence, name' + + # 取code的url,主要针对国内的先取code,再拿Token的方式 + code_endpoint = fields.Char(string='Token by Code Endpoint', help='Get Token from Code. Only for Code response type.') + user_template_id = fields.Many2one('res.users', string='New User Template', + domain=[('active', '=', False)]) diff --git a/app_saas/models/res_users.py b/app_saas/models/res_users.py new file mode 100644 index 00000000..66099fd7 --- /dev/null +++ b/app_saas/models/res_users.py @@ -0,0 +1,133 @@ +# -*- coding: utf-8 -*- + +try: + import urlparse +except: + from urllib.parse import urlparse +try: + import urllib2 +except: + from urllib import request as urllib2 + + + +from odoo import api, fields, models, _ +from odoo.exceptions import AccessDenied, UserError +from odoo.addons.auth_signup.models.res_users import SignupError +from odoo.http import request, Response +from odoo.tools.misc import ustr + +from ast import literal_eval +import json +import requests +from datetime import timedelta +import random + +import logging +_logger = logging.getLogger(__name__) + +class OauthBindError(Exception): + # 增加一种错误类型 + pass + +class ResUsers(models.Model): + _inherit = 'res.users' + + @api.model + def auth_oauth(self, provider, params): + # 这里原生是没处理code模式,此处将增加使用code取token,不在 controller 中处理 + code = params.get('code', False) + access_token = params.get('access_token') + oauth_provider = self.env['auth.oauth.provider'].sudo().browse(provider) + + kw = {} + if oauth_provider.code_endpoint and code and not access_token: + # odoo 特殊处理,用code取token + params.update({ + 'scope': oauth_provider.scope or '', + 'client_id': oauth_provider.client_id or '', + }) + if hasattr(oauth_provider, 'client_secret') and oauth_provider.client_secret: + params.update({ + 'client_secret': oauth_provider.client_secret or '', + }) + response = requests.get(oauth_provider.code_endpoint, params=params, timeout=30) + if response.ok: + ret = response.json() + # todo: 客户机首次连接时,取到的 server 端 key 写入 provider 的 client_secret + if ret.get('push_client_secret') and hasattr(oauth_provider, 'client_secret'): + oauth_provider.write({'client_secret': ret.get('push_client_secret')}) + self._cr.commit() + kw = {**ret, **params} + kw.pop('code', False) + self = self.with_context(auth_extra=kw) + res = super(ResUsers, self).auth_oauth(provider, kw) + return res + + def _auth_oauth_signin(self, provider, validation, params): + # 用户绑定的额外处理,如果有同 login 用户则直接绑定 + # todo: 当前不管多公司,在 social_login 里有更细节判断,后续优化 + # todo: 当前同名就写 oauth 信息,不安全,要优化 + oauth_provider = self.env['auth.oauth.provider'].sudo().browse(provider) + if oauth_provider and oauth_provider.scope.find('odoo') >= 0: + oauth_uid =validation.get('user_id') + if oauth_uid: + odoo_user = self.sudo().search([('login', '=', oauth_uid)], limit=1) + if odoo_user and not (odoo_user.oauth_access_token and odoo_user.oauth_provider_id and odoo_user.oauth_uid): + vals = { + 'oauth_provider_id': provider, + 'oauth_access_token': params.get('access_token'), + 'oauth_uid': oauth_uid, + } + odoo_user.write(vals) + _logger.info('========= _auth_oauth_signin res.users write:%s' % vals) + self._cr.commit() + return odoo_user.user_id.login + res = super(ResUsers, self)._auth_oauth_signin(provider, validation, params) + return res + + def _create_user_from_template(self, values): + # 处理odooapp.cn 为 server 时 默认为内部用户 + oauth_provider_id = values.get('oauth_provider_id') + if oauth_provider_id: + provider = request.env['auth.oauth.provider'].sudo().browse(int(oauth_provider_id)) + if provider: + template_user = provider.user_template_id + if not template_user and provider.scope.find('odoo') >= 0: + template_user = self.sudo().env.ref('base.default_user', False) + if not template_user: + template_user_id = literal_eval(self.env['ir.config_parameter'].sudo().get_param('base.template_portal_user_id', 'False')) + template_user = self.sudo().browse(template_user_id) + + if not values.get('login'): + raise ValueError(_('Signup: no login given for new user')) + if not values.get('partner_id') and not values.get('name'): + raise ValueError(_('Signup: no name or partner given for new user')) + + # create a copy of the template user (attached to a specific partner_id if given) + values['active'] = True + try: + with self.env.cr.savepoint(): + return template_user.sudo().with_context(no_reset_password=True).copy(values) + except Exception as e: + # copy may failed if asked login is not available. + raise SignupError(ustr(e)) + res = super(ResUsers, self)._create_user_from_template(values) + self._cr.commit() + return res + + @api.model + def _generate_signup_values(self, provider, validation, params): + # 此处生成 创建 odoo user 的初始值,增加字段如头像 + res = super()._generate_signup_values(provider, validation, params) + # 后置增加字段,包括 headimgurl + if validation.get('mobile'): + res['mobile'] = validation.get('mobile') + if validation.get('headimgurl'): + res['image_1920'] = self.sudo()._get_image_from_url(validation.get('headimgurl')) + return res + + def _rpc_api_keys_only(self): + # 可直接使用 oauth_access_token 作为 password 登录 + self.ensure_one() + return self.oauth_access_token or super()._rpc_api_keys_only() diff --git a/app_saas/static/description/banner.png b/app_saas/static/description/banner.png index db48c7e8..d24cc22d 100644 Binary files a/app_saas/static/description/banner.png and b/app_saas/static/description/banner.png differ diff --git a/app_saas/static/description/banner1.png b/app_saas/static/description/banner1.png index 08b91f6c..95692152 100644 Binary files a/app_saas/static/description/banner1.png and b/app_saas/static/description/banner1.png differ diff --git a/app_saas/static/description/banner2.png b/app_saas/static/description/banner2.png new file mode 100644 index 00000000..8557815e Binary files /dev/null and b/app_saas/static/description/banner2.png differ diff --git a/app_saas/static/description/banner3.png b/app_saas/static/description/banner3.png new file mode 100644 index 00000000..de86dec9 Binary files /dev/null and b/app_saas/static/description/banner3.png differ diff --git a/app_saas/static/description/cnreadme.jpg b/app_saas/static/description/cnreadme.jpg new file mode 100644 index 00000000..67004a79 Binary files /dev/null and b/app_saas/static/description/cnreadme.jpg differ diff --git a/app_saas/static/description/demo1.jpg b/app_saas/static/description/demo1.jpg index f53cf780..f9ebf635 100644 Binary files a/app_saas/static/description/demo1.jpg and b/app_saas/static/description/demo1.jpg differ diff --git a/app_saas/static/description/demo2.jpg b/app_saas/static/description/demo2.jpg new file mode 100644 index 00000000..f53cf780 Binary files /dev/null and b/app_saas/static/description/demo2.jpg differ diff --git a/app_saas/static/description/demo3.jpg b/app_saas/static/description/demo3.jpg new file mode 100644 index 00000000..e8d83662 Binary files /dev/null and b/app_saas/static/description/demo3.jpg differ diff --git a/app_saas/static/description/demo4.jpg b/app_saas/static/description/demo4.jpg new file mode 100644 index 00000000..46fd516d Binary files /dev/null and b/app_saas/static/description/demo4.jpg differ diff --git a/app_saas/static/description/demo5.jpg b/app_saas/static/description/demo5.jpg new file mode 100644 index 00000000..9cfee165 Binary files /dev/null and b/app_saas/static/description/demo5.jpg differ diff --git a/app_saas/static/description/index.html b/app_saas/static/description/index.html index 15f7d1e3..3d64d99c 100644 --- a/app_saas/static/description/index.html +++ b/app_saas/static/description/index.html @@ -8,8 +8,8 @@
-

odooapp.cn SaaS Client.Odoo中文应用商店SaaS云服务客户端

-

快速访问Odoo中文应用商店并获取独享Odoo中文通行码

+

Ai通行证.Odoo中文应用商店SaaS云服务客户端,一键微信QQ淘宝抖音全媒体登录SSO

+

odooapp.cn SaaS Client-Ai Passport.SSO with

一键获取最新应用信息,最新行业服务包,一键获取Odoo中文翻译更新,快速获取Odoo服务,Odoo升级评估

@@ -17,17 +17,59 @@
-

启用后快速获取Odoo中文应用商店模块及行业方案

-

未经用户明确同意,本应用不会获取任何用户系统数据

+

1.启用后即可使用 odooapp.cn 提供的全网社交媒体整合登录

+

支持微信、抖音、QQ、淘宝、钉钉、支付宝、企业微信、Facebook、Google、微软Azure等整合登录。

+

未经用户明确同意,本应用不会获取任何用户系统数据.

相关内容,请参考用户协议及我们的隐私政策:

https://www.odooapp.cn/conditions

https://www.odooapp.cn/privacy-policy

+
+ +
+

用户可直接调用SSO一键登录

+
+
+

2. 快速访问Odoo中文应用商店并获取独享Odoo中文通行码,可随时断开云服务连接

+

启用云服务后,即可获取最新功能推送,版本比对信息,提供版本升级建议

+
+ +
+
+
+ +
+
+

标准的Oauth2登录支持,可方便配置

+

安装后,用户即可使用 odooapp.cn 提供的 Ai通行证进行登录

+
+ +
+

可以使用微信抖音QQ等在Odoo中文应用商店登录,同意并继续后即可登入自有Odoo

+
+ +
+

自定义默认用户模板,为用户启用不同权限

+
+ +
+
+
+ +
+
+

相关服务正在紧张开发中,后续可享用更多服务

+
+ +
+
+
+ diff --git a/app_saas/views/auth_oauth_provider_views.xml b/app_saas/views/auth_oauth_provider_views.xml new file mode 100644 index 00000000..83fa29b0 --- /dev/null +++ b/app_saas/views/auth_oauth_provider_views.xml @@ -0,0 +1,16 @@ + + + + app.auth.oauth.provider.form + auth.oauth.provider + + + + + + + + + + +