Odoo Help


odoo Call method written in old API from method written in new API

on 8/28/15, 3:20 AM 4,530 views


I am trying to create new module from new API,I don't want to write cr ,uid, ids, or self._cr, self._uid and other things.

If there are method written in old API style and I want to call it from new API then how to call

Suppose I want to call duplicate_template method in project module

right now I need to call same as old style

new_project_template = self.pool.get('project.project').duplicate_template(self._cr, self._uid, [my_project_template.id], context = context) 

but I want to call as a new API style

new_project_template = self.env['project.project'].duplicate_template(my_project_template.id]) 


new_project_template = self.env['project.project'].duplicate_template(self._cr, self._uid, [my_project_template.id], context = context)

is it possible ?

Thank's for reply.

Missing api decorator for this function (project has not been converted in new api)...

Jérémy Kersten (jke)
on 8/28/15, 3:50 AM

Anil R. Kesariya

--Anil R. Kesariya--
| 7 6 8
Rajkot, India
--Anil R. Kesariya--

Odoo Techno Functional Expert

* Engaged with odoo since May - 2012.

* Customise existing module or develop new module base on customer requirement.

* Played key developer role in many past and running projects.

* Expert in requirement gathering of business and transforming requirement into odoo platform.

* Major expertise in core modules, database, report development and theme development.

* Integration expert.

Linkedin  : https://in.linkedin.com/in/anil-kesariya-97b20a66

Anil R. Kesariya
On 8/28/15, 4:24 AM

Hello Sagar,

You can only call the methods in new api coding standard those are defined or (Definition) written in  new api coding standard.

Like Base module's methods (Create,write,unlink,copy,name_get etc) this method can be called with new coding standard.

But those method already defined in old coding standard than you have to pass argument while calling it.

So, you have to follow this way.

new_project_template = self.env['project.project'].duplicate_template(self._cr, self._uid, [my_project_template.id], self._context)

But make sure your current method is defined in new coding standard means you are using decorators in your method while calling this method. otherwise you can not define object using self.env

Otherwise you have to use:

new_project_template = self.pool.get('project.project').duplicate_template(cr, uid, [my_project_template.id], context = context) 

While you are calling methods those are written in old standard you have to pass all those arguments.

Hope this will help.



About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 8/28/15, 3:20 AM
Seen: 4530 times
Last updated: 8/28/15, 4:24 AM