- 在controller添加一个test方法, 不需参数
@http.route(‘/test‘, type = ‘json‘, auth = ‘public‘) def test(self): phases = http.request.env[‘project.task.type‘].search([]) list = [] dic = {} for phase in phases: list.append(phase.name) dic[‘phases‘] = list return json.dumps(dic)
注意:project.task.type 这个model需要设置为公开的群组访问控制
- 打开终端:
curl ‘http://localhost:8069/test‘ -H ‘Content-Type: application/json‘ --data "{}"
时间: 2024-10-11 21:11:35