Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Method decorators in odoo9

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 269
    Comment on it

    Method decorators is most important part of the Odoo, it method decorators provides the elements for managing two different API styles, which is "traditional" and "record" styles.
    In the "traditional" style, parameters like the database cursor, user id, context dictionary and record ids are passed explicitly to all methods. In the "record" style, those parameters are hidden into model instances, which gives it a more object-oriented feel.
    For example you can see below code-

    model = self.pool.get(MODEL)
    ids = model.search(cr, uid, DOMAIN, context=context)
    for rec in model.browse(cr, uid, ids, context=context):
        print rec.name
    model.write(cr, uid, ids, VALUES, context=context)
    env = Environment(cr, uid, context) # cr, uid, context wrapped in env
    model = 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)   
    

 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: