odoo fileupload via controller
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. import base64 from collections import OrderedDict from datetime import datetime from odoo import http from odoo.exceptions import AccessError, MissingError from odoo.http import request, Response from odoo.tools import image_process from odoo.tools.translate import _ from odoo.addons.portal.controllers import portal from odoo.addons.portal.controllers.portal import pager as portal_pager from odoo import http from odoo.http import request, serialize_exception from odoo import api, SUPERUSER_ID class SapbotUpload(http.Controller): @http .route( '/sapbot/' , auth = 'user' , type = 'http' , csrf = False ) # @serialize_exception def sapbot_upload( self , file , filetype): file .save(r 'D:\www\odoo\data\1.xlsx' ) return request.render( 'sapbot.thanks' ) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <form class = "needs-validation" action = "/sapbot/" target = "_blank" method = "POST" name = "sapbot" id = "sapbot" enctype = "multipart/form-data" > <! - - < input type = "hidden" name = "csrf_token" t - att - value = "request.csrf_token()" / > - - > <div class = "row g-3" > <div class = "col-md-6" > <label class = "form-label" >选择文件:< / label> < input type = "file" class = "form-control" id = "file" name = "file" / > < / div> <div class = "col-md-2" > <label class = "form-label" >任务类别< / label> <select class = "form-select" id = "filetype" name = "filetype" > <option>MM_Auto< / option> <option>MM< / option> <option>BOM(暂未开通)< / option> <option>其他(暂未开通)< / option> < / select> < / div> <hr class = "my-4" / > < / div> < input type = "submit" class = "w-40 btn btn-primary btn-lg" value = "提交" / > < / form> |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
2018-10-25 scrapy 日志处理
2018-10-25 sqlalchemy多对多查询
2018-10-25 sqlalchemy 多对多关系
2018-10-25 django实现类似触发器的效果
2018-10-25 django 上传文件及反馈信息
2018-10-25 django 获取错误信息