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 ...
随机推荐
- 莫比乌斯环-vtkTriangleStrip
#ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRend ...
- ViewHolder的改进写法
先看看ViewHolder通用写法 ViewHolder holder = null; if(convertView == null){ ...
- (zz)linux awk
博文转载自http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2858470.html 谢谢原作者.条理很清楚,由浅入深.敲了每一行命令,正确无误. ...
- Memcached集群/分布式/高可用 及 Magent缓存代理搭建过程 详解
当网站访问量达到一定时,如何做Memcached集群,又如何高可用,是接下来要讨论的问题. 有这么一段文字来描述“Memcached集群” Memcached如何处理容错的? 不处理!:) 在memc ...
- 详细解读Android中的搜索框—— SearchView
以前总是自己写的 今天看看别人做的 本篇讲的是如何用searchView实现搜索框,其实原理和之前的没啥差别,也算是个复习吧. 一.Manifest.xml 这里我用一个activity进行信息的输入 ...
- redis集群之REDIS CLUSTER
redis集群之REDIS CLUSTER 时间 2016-04-11 17:05:00 NoSQL_博客园 原文 http://www.cnblogs.com/zhanchenjin/p/537 ...
- Linux IO模式及 select、poll、epoll详解
linux的IO调度文章==> https://segmentfault.com/a/1190000003063859?hmsr=toutiao.io&utm_medium=toutia ...
- testng 教程之使用参数的一些tricks配合使用reportng
前两次的总结:testng annotation生命周期 http://www.cnblogs.com/tobecrazy/p/4579414.html testng.xml的使用和基本配置http: ...
- [转] ImageView的android:adjustViewBounds属性
原文链接:http://blog.csdn.net/pingchuanyang/article/details/9252689 取值为true时: Adjust the ImageView's b ...
- [转]Android样式的开发:shape篇
转载自Keegan小钢原文链接:http://keeganlee.me/post/android/20150830 Android样式的开发:shape篇Android样式的开发:selector篇A ...