odoo后台调用路由接口
1 2 3 | from odoo.exceptions import UserError import requests from odoo.http import request |
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 | def action_commit_approval( self ,action_type = 'commit_approval' ): """ action_type : commit_approval/cancel_approval """ self .ensure_one() base_url = self .env[ 'ir.config_parameter' ].sudo().get_param( 'web.base.url' , default = 'http://localhost:8069' ) data = { 'model_name' : self ._name, 'res_id' : self . id , 'action_type' : action_type } session = request.session opener = requests.Session() opener.cookies[ 'session_id' ] = session.sid res = opener.post(url = base_url + '/web/dataset/control_approval' , json = { 'params' : data}) resp = json.loads(res.content) if resp.get( 'result' ) and resp[ 'result' ].get( 'state' ) = = 1 : print ( '提交审批成功1' ) res = opener.post(url = base_url + '/web/dataset/instance_get_info' ,json = { 'params' : data}) resp = json.loads(res.content) if resp.get( 'result' ): print ( '提交审批成功2' ,resp.get( 'result' ).get( 'approval_state' )) else : error = resp.get( 'error' ).get( 'data' ).get( 'message' ) raise UserError(error) |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
2019-05-21 permission 权限清单
2019-05-21 aria2 https
2019-05-21 aria2 资料
2019-05-21 aria2 cmd set chmod, and others..