Odoo 8.0 New API's environment

Source: Internet
Author: User

"" 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. ""     

The Environment class provides encapsulation of an ORM object, provides access to the registration class, caches the Recordset, and manages the data structure of the recalculation.

For classes that inherit the model, the environment can be manipulated directly through self.env.

Property list:

1.user: Returns the current user

Self.env.user

2.lang: Returns the current language code

Self.env.lang

3.in_draft: Returns whether in draft mode

Self.env.in_draft

4.in_onchange: Returns whether in ' onchange ' draft mode

Self.env.in_onchange

There are also attributes such as Cr,registery,cache,prefetch,computed,dirty,todo,mode,all

Application notes:

1. Use Env[model] to get the class object:

self.env[' Ir.model '].search ([' State ', '! = ', ' manual ')])

2. Execute SQL statements using CR:

Self.env.cr.execute (query, (value,))

Odoo 8.0 New API's environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.