当前位置: 首页 > news >正文

odoo16版本的render变更

今天在整理文件上传功能时,发现

odoo16的ir_ui_view.py中_render方法不见了,引用出错AttributeError: 'ir.ui.view' object has no attribute '_render'

    def _render(self, values=None, engine='ir.qweb', minimal_qcontext=False):assert isinstance(self.id, int)qcontext = dict() if minimal_qcontext else self._prepare_qcontext()qcontext.update(values or {})return self.env[engine]._render(self.id, qcontext)@api.modeldef _prepare_qcontext(self):""" Returns the qcontext : rendering context with website specific value (requiredto render website layout template)"""qcontext = dict(env=self.env,user_id=self.env["res.users"].browse(self.env.user.id),res_company=self.env.company.sudo(),keep_query=keep_query,request=request,  # might be unbound if we're not in an httprequest contextdebug=request.session.debug if request else '',test_mode_enabled=bool(config['test_enable'] or config['test_file']),json=json_scriptsafe,quote_plus=werkzeug.urls.url_quote_plus,time=safe_eval.time,datetime=safe_eval.datetime,relativedelta=relativedelta,xmlid=self.sudo().key,viewid=self.id,to_text=pycompat.to_text,image_data_uri=image_data_uri,# specific 'math' functions to ease rounding in templates and lessen controller marshmallingfloor=math.floor,ceil=math.ceil,)return qcontext

仔细一追,变的还不少

# 以下四行为与15引
import werkzeug, werkzeug.urls
from odoo.tools.json import scriptsafe as json_scriptsafe
from dateutil.relativedelta import relativedelta
from odoo.tools.image import image_data_uri

AttributeError: 'ir.ui.view' object has no attribute '_render'

    # ----------------------------------------------------------# Functions# ----------------------------------------------------------def get_and_update_onbarding_state(self, onboarding_state, steps_states):"""odoo15有,16版本去除了 Needed to display onboarding animations only one time. """old_values = {}all_done = Truefor step_state in steps_states:old_values[step_state] = self[step_state]if self[step_state] == 'just_done':self[step_state] = 'done'all_done = all_done and self[step_state] == 'done'if all_done:if self[onboarding_state] == 'not_done':# string `onboarding_state` instead of variable name is not an errorold_values['onboarding_state'] = 'just_done'else:old_values['onboarding_state'] = 'done'self[onboarding_state] = 'done'return old_values

以后用到render方法时只用借用新的

request.env["ir.qweb"]中的render了

相关文章:

  • 学习Uni-app开发小程序Day23
  • 06.部署jpress
  • Sublime Text 基础教程(个人总结)
  • 机器学习之爬山算法(Hill Climbing Algorithm)
  • 【OpenVINO™】在C#中使用 OpenVINO™ 部署 YOLOv10 模型实现目标
  • 多线程笔记
  • 浙江大学数据结构MOOC-课后习题-第九讲-排序3 Insertion or Heap Sort
  • git多人开发,不用merge的操作方法,阿里codeup
  • 柳宗元,政治坎坷与文学辉煌的交织
  • 多线程基本常识
  • 实现按块复制元素的进阶技巧
  • 邦芒职场:揭秘影响你职场收入的九大细节
  • 15、设计模式之责任链模式
  • java入门 springboot上传文件
  • vue3 ts问题 找不到模块“@/views/home/index.vue”或其相应的类型声明。
  • 【5+】跨webview多页面 触发事件(二)
  • 【vuex入门系列02】mutation接收单个参数和多个参数
  • cookie和session
  • Java 最常见的 200+ 面试题:面试必备
  • Linux快速配置 VIM 实现语法高亮 补全 缩进等功能
  • mysql 5.6 原生Online DDL解析
  • PHP变量
  • Python_网络编程
  • React 快速上手 - 06 容器组件、展示组件、操作组件
  • SQLServer之索引简介
  • tab.js分享及浏览器兼容性问题汇总
  • Transformer-XL: Unleashing the Potential of Attention Models
  • Vue 2.3、2.4 知识点小结
  • webgl (原生)基础入门指南【一】
  • webpack项目中使用grunt监听文件变动自动打包编译
  • 从0实现一个tiny react(三)生命周期
  • 从零开始在ubuntu上搭建node开发环境
  • 关于Flux,Vuex,Redux的思考
  • 那些年我们用过的显示性能指标
  • 微服务入门【系列视频课程】
  • 小程序开发之路(一)
  • 学习HTTP相关知识笔记
  • 智能合约Solidity教程-事件和日志(一)
  • 1.Ext JS 建立web开发工程
  • shell使用lftp连接ftp和sftp,并可以指定私钥
  • 曜石科技宣布获得千万级天使轮投资,全方面布局电竞产业链 ...
  • ​secrets --- 生成管理密码的安全随机数​
  • ​软考-高级-系统架构设计师教程(清华第2版)【第1章-绪论-思维导图】​
  • # .NET Framework中使用命名管道进行进程间通信
  • #使用清华镜像源 安装/更新 指定版本tensorflow
  • $.ajax()
  • (env: Windows,mp,1.06.2308310; lib: 3.2.4) uniapp微信小程序
  • (第27天)Oracle 数据泵转换分区表
  • (附源码)ssm基于jsp的在线点餐系统 毕业设计 111016
  • (附源码)ssm经济信息门户网站 毕业设计 141634
  • (附源码)计算机毕业设计高校学生选课系统
  • (个人笔记质量不佳)SQL 左连接、右连接、内连接的区别
  • (三)终结任务
  • (转)jQuery 基础
  • .desktop 桌面快捷_Linux桌面环境那么多,这几款优秀的任你选