mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
fix get_ua_type
This commit is contained in:
@@ -45,6 +45,7 @@
|
|||||||
''',
|
''',
|
||||||
'depends': [
|
'depends': [
|
||||||
'base',
|
'base',
|
||||||
|
'app_common',
|
||||||
'base_setup',
|
'base_setup',
|
||||||
'mail',
|
'mail',
|
||||||
'queue_job',
|
'queue_job',
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import datetime
|
|||||||
# from transformers import TextDavinciTokenizer, TextDavinciModel
|
# from transformers import TextDavinciTokenizer, TextDavinciModel
|
||||||
from odoo import api, fields, models, tools, _
|
from odoo import api, fields, models, tools, _
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
|
from odoo.addons.app_common.models.base import get_ua_type
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
@@ -65,7 +66,7 @@ class Channel(models.Model):
|
|||||||
param = self.get_ai_config(ai)
|
param = self.get_ai_config(ai)
|
||||||
res, usage, is_ai = ai.get_ai(messages, author_id, answer_id, param)
|
res, usage, is_ai = ai.get_ai(messages, author_id, answer_id, param)
|
||||||
if res:
|
if res:
|
||||||
if self.get_ua_type() != 'wxweb':
|
if get_ua_type() != 'wxweb':
|
||||||
# 处理当微信语音返回时,是直接回文本信息,不需要转换回车
|
# 处理当微信语音返回时,是直接回文本信息,不需要转换回车
|
||||||
res = res.replace('\n', '<br/>')
|
res = res.replace('\n', '<br/>')
|
||||||
new_msg = channel.with_user(user_id).message_post(body=res, message_type='comment', subtype_xmlid='mail.mt_comment', parent_id=message.id)
|
new_msg = channel.with_user(user_id).message_post(body=res, message_type='comment', subtype_xmlid='mail.mt_comment', parent_id=message.id)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class AppController(http.Controller):
|
|||||||
# https://github.com/selwin/python-user-agents
|
# https://github.com/selwin/python-user-agents
|
||||||
ua_string = request.httprequest.headers.get('User-Agent')
|
ua_string = request.httprequest.headers.get('User-Agent')
|
||||||
user_agent = parse(ua_string)
|
user_agent = parse(ua_string)
|
||||||
ua_type = self.get_ua_type()
|
ua_type = get_ua_type()
|
||||||
ustr = "Request UA: <br/> %s <br/>Parse UA: <br/>%s <br/>UA Type:<br/>%s <br/>" % (ua_string, str(user_agent), ua_type)
|
ustr = "Request UA: <br/> %s <br/>Parse UA: <br/>%s <br/>UA Type:<br/>%s <br/>" % (ua_string, str(user_agent), ua_type)
|
||||||
return request.make_response(ustr, [('Content-Type', 'text/html')])
|
return request.make_response(ustr, [('Content-Type', 'text/html')])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user