zoukankan      html  css  js  c++  java
  • 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,))
  • 相关阅读:
    java多线程小节, 总结的不错
    奇瑞风云, 你还在路上么
    android NDK 环境建立
    外企下岗白领正成为“新4050”
    搭积木
    祝MORIENTES在LIVERPOOL有所成就
    简单生活
    为什么要更新
    归去来
    随记一笔
  • 原文地址:https://www.cnblogs.com/kfx2007/p/3894723.html
Copyright © 2011-2022 走看看