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

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

By
Suhas
on 8/28/15, 3:20 AM 2,713 views

Hello,

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]) 

OR

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
0

Anil R. Kesariya

--Anil R. Kesariya--
4321
| 6 5 8
Gandhinagar, India
--Anil R. Kesariya--
ERP Consultant

Key Skill
-
Technical & Functional Expert
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.


Rgds,

Anil.


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

1 follower(s)

Stats

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