Odoo 8.0 new API 之Environment

來源:互聯網
上載者:User

標籤:des   style   blog   color   io   資料   for   ar   

 """ 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,))

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.