让AI写Odoo服务器动作时的注意事项 - xiaohao0576/odoo-doc GitHub Wiki

  1. 服务器动作中不能使用 return,最终结果赋值给 action 变量由 Odoo 返回
  2. 不能随意 import 模块,只能使用 _get_eval_context 注入的对象:request, json, env, b64encode, b64decode, time, datetime, log
  3. 只有安装了website模块,才能使用 request 对像
  4. 如果要POST数据到服务器动作,一定要先获取 csrf_token , 代码是csrf_token = request.csrf_token(), 然后在提交的数据中加入csrf_token字段