Odoo 8.0 new API 之Environment
""" An environment wraps data for ORM records:
- :attr:`cr`, the current database cursor;
- :attr:`uid`, the current user id;
- :attr:`context`, the current context dictionary.
It also provides access to the registry, a cache for records, and a data
structure to manage recomputations.
"""
Environment类提供了对ORM对象的封装,同时提供了对注册类的访问,记录集的缓存,以及管理重计算的数据结构.
对于继承了Model的类来说可以直接通过self.env对Environment进行操作.
属性列表:
1.user:返回当前用户
self.env.user
2.lang:返回当前语言代码
self.env.lang
3.in_draft:返回是否处于草稿模式
self.env.in_draft
4.in_onchange:返回是否处于'onchange'草稿模式
self.env.in_onchange
另外还有cr,registery,cache,prefetch,computed,dirty,todo,mode,all等属性
应用说明:
1.利用env[model]获取类对象:
self.env['ir.model'].search([('state', '!=', 'manual')])
2.利用cr执行sql语句:
self.env.cr.execute(query, (value,))
Odoo 8.0 new API 之Environment的更多相关文章
- Odoo 8.0 new API 概述
相对于7来说,8的api改进了不少,用官方的话来说就是更加面向对象了. 下面探究一下具体的改动. 准备知识:python装饰器的使用 http://blog.csdn.net/thy38/articl ...
- Odoo 8.0 new API 之constrains装饰
constrains装饰用于对字段进行限制 应用举例: 定义列: age = fields.Integer(string="age") 方法: @api.constrains('a ...
- Odoo 8.0 new API 之model 装饰
model装饰器的作用是返回一个集合列表 应用举例: 定义columns langs = fields.Selection(string="Lang",selection=&quo ...
- Odoo 8.0 new API 之one装饰
one装饰器的作用是对每一条记录都执行对应的方法,相当于traditional-style中的function 应用举例: 定义的columns now = fields.Datetime(compu ...
- 【转】odoo学习之:API整合文档
Odoo8.0新API文档 一.新API概述 在8中,api接口分为traditaional style和record style,traditional style指的就是我们在7中使用的类型,de ...
- ASP.NET CORE 1.0 MVC API 文档用 SWASHBUCKLE SWAGGER实现
from:https://damienbod.com/2015/12/13/asp-net-5-mvc-6-api-documentation-using-swagger/ 代码生成工具: https ...
- 配置ubuntu 14.04.3 LTS odoo 9.0开发环境
使用VMware Fusion 8.0.1创建ubuntu 64bit虚拟机:使用ubuntu-14.04.3-desktop-amd64.iso镜像缺省安装ubuntu,用户名odoo,密码1234 ...
- 配置Windows 2008 R2 64位 Odoo 8.0 源码PyCharm开发调试环境
安装过程中,需要互联网连接下载python依赖库: 1.安装: Windows Server 2008 R2 x64标准版 2.安装: Python 2.7.10 amd64 到C:\Python27 ...
- Zepto,Zepto API 中文版,Zepto 中文手册,Zepto API,Zepto API 中文版,Zepto 中文手册,Zepto API 1.0, Zepto API 1.0 中文版,Zepto 1.0 中文手册,Zepto 1.0 API-translate by yaotaiyang
Zepto,Zepto API 中文版,Zepto 中文手册,Zepto API,Zepto API 中文版,Zepto 中文手册,Zepto API 1.0, Zepto API 1.0 中文版,Z ...
随机推荐
- solr-web界面增加登录认证
目录 配置tomcat-user.xml 配置web.xml 界面展示 回到顶部 配置tomcat-user.xml 找到 tomcat 下 conf 文件下增加 tomcat-user.xml &l ...
- 2014 Multi-University Training Contest 9#1009
Just a JokeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Tot ...
- PHP中类的继承和构造函数的继承
PHP4.x 版本: PHP 4.x 的构造函数名与类名相同. 子类的构造函数名与子类名相同(废话). 在子类里父类的构造函数不会自动执行. 要在子类里执行父类的构造函数,必须执行类似以下语句: $t ...
- ahjesus Axure RP 7.0注册码
ahjesus Axure RP 7.0注册码 用户名:axureuser 序列号:8wFfIX7a8hHq6yAy6T8zCz5R0NBKeVxo9IKu+kgKh79FL6IyPD6lK7G6+t ...
- http协议相关-待续
// 关于http的东西 function httpAction() { // http://localhost/blog/testurl.php?id=5 到目前为止 // 获取当前域名 // 获取 ...
- [转]在MyEclipse中设置struts.xml自动提示功能
导入标签:<%@ taglib uri="/struts-tags" prefix="s" %> 要想在MyEclipse中实现struts.xml ...
- 《sqoop实现hdfs中的数据导出至mysql数据库》
报错Access denied for user 'root'@'localhost' (using password: YES) 参考一 参考二 登陆mysql时,root密码的修改 参考帖子h ...
- winrt简单克隆对象
public MapPoint Copy()//MapPoint克隆方法 { MapPoint p = new MapPoint();//这是我自定义的对象 //利用反射获得类成员 FieldInfo ...
- 25条提高iOS App性能的建议和技巧
这篇文章来自iOS Tutorial Team 成员 Marcelo Fabri, 他是 Movile 的一个iOS开发者. Check out his personal website or fol ...
- iOS 图片选择器 总结
UIImagePickerController #pragma mark 从用户相册获取活动图片 - (void)pickImageFromAlbum{ imagePicker = [[UIImage ...