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 ...
随机推荐
- UVA-11991 Easy Problem from Rujia Liu?
Problem E Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
- CentOS Linux系统下更改Apache默认网站目录
引言: Apache默认的网站目录是在/var/www/html,我们现在要把网站目录更改到/home/wwwroot/web1/htdocs,操作如下 准备工作: 创建目录: cd /home mk ...
- UVA2322
题目:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- [BZOJ3173][Tjoi2013]最长上升子序列
[BZOJ3173][Tjoi2013]最长上升子序列 试题描述 给定一个序列,初始为空.现在我们将1到N的数字插入到序列中,每次将一个数字插入到一个特定的位置.每插入一个数字,我们都想知道此时最长上 ...
- SQL,Linq,Lambda之间的转换练习
1.查询Student表中的所有记录的Sname.Ssex和Class列. SQL:select sname,ssex,class from Students linq:from s in Stude ...
- 使用jvisualvm.exe 的Btrace插件介绍/使用教程
一.背景 在生产环境中可能经常遇到各种问题,定位问题需要获取程序运行时的数据信息,如方法参数.返回值.全局变量.堆栈信息等.为了获取这些数据信息,我们可以 通过改写代码,增加日志信息的打 ...
- opendrive
opendrive和其他许多网盘一样.注册拥有5G的免费空间.每天1G的免费外链流量.更重要的是,他能够给你提供一个直接外链!这是国内外许多网盘都没有的.当你上载了一个MP3,你想用直接外链的形式在博 ...
- Spring的测试
spring测试要引用junit及spring-test <dependency> <groupId>junit</groupId> <artifactId& ...
- 使用emIDE创建STM32项目
emIDE是一个开源的嵌入式集成开发环境,基于Code::Blocks开发,能够支持多个平台和多个厂家的嵌入式硬件,继承了Code::Blocks的有点. 下载emIDE并安装,也可选择绿色版.若需要 ...