Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
pengyuthon
2026-02-28 09:37:59 +08:00
2 changed files with 23 additions and 17 deletions
+22 -16
View File
@@ -9,9 +9,13 @@ from odoo.http import request, content_disposition
from jinja2 import Environment, PackageLoader
import mammoth
import logging
_logger = logging.getLogger(__name__)
class preview(http.Controller):
@http.route('/web/content/preview/<int:id>', type='http', method=['Get'], auth="public")
@http.route('/web/content/preview/<int:id>', type='http', method=['Get'], auth="user")
def content_preview(self, id=None):
ir_attach = request.env['ir.attachment'].sudo()
attach = ir_attach.browse(id)
@@ -36,21 +40,23 @@ class preview(http.Controller):
# return template.render(html=html)
elif attach.mimetype in excel or word:
# 'http://view.officeapps.live.com/op/view.aspx?src=https://oa.thtzjt.com/web/content/office_preview/'
office_view_url = 'http://view.officeapps.live.com/op/view.aspx?src='
base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url')
html = f'{office_view_url}{quote(base_url + "/web/content/office_preview/" + str(attach.id))}'
return werkzeug.wrappers.Response(f"""
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body onLoad="parent.location='{html}'">
</body>
</html>
""", status=200, headers=[('Content-Type', 'text/html'), ('charset', 'utf-8')])
# office_view_url = 'http://view.officeapps.live.com/op/view.aspx?src='
# base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url')
# html = f'{office_view_url}{quote(base_url + "/web/content/office_preview/" + str(attach.id))}'
target_url = f'/onlyoffice/editor/{str(attach.id)}'
return werkzeug.utils.redirect(target_url)
# return werkzeug.wrappers.Response(f"""
# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
# "http://www.w3.org/TR/html4/loose.dtd">
# <html>
# <head>
# <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
# <title></title>
# </head>
# <body onLoad="parent.location='{html}'">
# </body>
# </html>
# """, status=200, headers=[('Content-Type', 'text/html'), ('charset', 'utf-8')])
else:
return werkzeug.wrappers.Response('This format is not currently supported', status=200, headers=[('Content-Type', 'text/html'),('charset','utf-8')])
@@ -275,7 +275,7 @@
<field name="model">soong.workflow.record</field>
<field name="arch" type="xml">
<tree string="已办流程" action="open_record" type="object" js_class="wkf_record_list_view"
decoration-muted="approve_state == 'end'" decoration-warning="approve_state != 'end'"
decoration-warning="approve_state != 'end'"
delete="false"
default_order="write_date2 desc, id desc" expand="1" limit="10">
<header>