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

How to access Odoo 8 methods from Odoo7

By
nishad
on 11/2/15, 6:50 AM 482 views

Hi,

Does anyone have an idea how to use an Odoo 8 method in Odoo 7 class / method ?

I have to use a specific method developed in Odoo 8 (New API) module in my traditional (Odoo 7) addon. How does it possible?


0
nishad
On 11/2/15, 8:27 AM

We have a work around for this. Define v7 & v8 compatible modules as follows,

@api.v7

def _validate_values(self,cr,uid,values,context=None):



@api.v8

def _validate_values(self,values):


And call the method like as follows to get result from both v7 & v8 ..

v7result = self.pool.get('hr.employee.rejoin')._validate_values(cr,uid,vals,context)

v8result = self._validate_values(values)

0

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 11/2/15, 7:09 AM

Hi,

If you are working with Odoo 8 and old api addon. You can use the decorators @api.model and @api.multi to make the new api methods callable from old api.

@api.multi def _validate_values(self,values): ...... return values How do i call this method from a traditional create function ? def create(self, cr, uid, vals, context=None): e = self.pool.get('hr.employee.rejoin')._validate_values(vals) Will this work ?? Nop..

nishad
on 11/2/15, 7:12 AM

No you need to call like calling an old api function. Like, e = self.pool.get('hr.employee.rejoin')._validate_values(cr, uid, ids, vals, context=None)

Akhil P Sivan
on 11/2/15, 8:18 AM

No Akhil , It wont't work as expected.. It throws an error.. We have a work around for this. Define v7 & v8 compatible modules as follows, @api.v7 def _validate_values(self,cr,uid,values,context=None): @api.v8 def _validate_values(self,values): And call the method like as follows to get result from both v7 & v8 .. v7result = self.pool.get('hr.employee.rejoin')._validate_values(cr,uid,vals,context) v8result = self._validate_values(values)

nishad
on 11/2/15, 8:26 AM

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: 11/2/15, 6:50 AM
Seen: 482 times
Last updated: 11/2/15, 8:27 AM