Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
9604 Visualizzazioni

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.

Avatar
Abbandona

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

Risposta migliore

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.


Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
feb 22
5562
1
ago 20
4529
2
gen 20
15686
0
giu 16
2691
1
giu 16
3284