Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Environment in Odoo9

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 276
    Comment on it

    Environment is the most important part of set in any framework.its indicates stores various contextual data used by the ORM method . For example you can see below code in you .py file .

    @api.multi
    ... @api.returns('self')
    ... def demo_method(self):
    ...     return self
    new_demo_model = env['a.model'].browse(1, 2, 3)
     new_style_model.some_method()
    a.model(1, 2, 3)
     old_demo_model = pool['a.model']
    old_demo_model.some_method(cr, uid, [1, 2, 3], context=context)
    [1, 2, 3]
    env = Environment(cr, uid, context) # cr, uid, context wrapped in env
    demo = env[MODEL]                  # retrieve an instance of MODEL
    recs = model.search(DOMAIN)         # search returns a recordset
    for rec in recs:                    # iterate over the records
        print rec.name
    recs.write(VALUES)  

    Note with the help of this code you can set your environment easly.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: