Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

New API in Odoo 8.0

api
By
Sage
on 3/26/15, 2:30 AM 763 views

Hi Experts,


In the New API framework starting from Odoo 8, we have seen some decorator like api.one, api.multi which replace the cr, uid in prior version.

For example, in odoo 7, we need to locate a record using:

self.browse(cr,uid,[id])

In odoo 8, we can just decorate the method using @api.one

So my question is that,

1. Is there any improvement other than grammar while using the new API framework? For instance, performance improvement? 

2. If we don't use cr, how can we commit a transaction while using api.one/api.multi? 

From the document, it seems that while the operation self.name = value is executed, the field in SQL will be updated and transaction will also be committed.


Thanks a lot in advance.


Regards

Sage

1

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3883
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 3/26/15, 2:44 AM

when we use api decorators, the cr, uid, ids, context fields are not used when describing a method but these values are available in environment variables.

self._cr or self.env.cr
self._uid or self.env.uid
self._context or self.env.context 


I am not sure about the performance improvement.

to use commit, self.env.cr.commit()

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 3/26/15, 2:30 AM
Seen: 763 times
Last updated: 3/30/15, 1:54 AM