Odoo Help

0

How to create our own web service method in openerp?

By
Vivekrajan
on 5/27/13, 7:44 AM 2,043 views

Hi Dear Friends,

I would like to have my own web service methods newly or override the existing one. Can anybody suggest me how to do that?

Thanks

can you explain more or give an example?

Borni DHIFI
on 5/27/13, 7:59 AM

Right now, the standard openerp web service is based on the objects ( partner, sales order etc.). The operations are read, write, update,delete. The default methods just bring the values as it is in case I use the read method on a partner object. But I would like to override the method and do some changes. So that , the users of my webservice get the right data and in the right format

Vivekrajan
on 5/27/13, 8:20 AM
2

Borni DHIFI

--Borni DHIFI--
5182
| 6 8 9
Tunis, Tunisia
--Borni DHIFI--

Techno Functional Consultant Odoo(OpenERP) 

http://www.linkedin.com/in/borni

Skype : dhifi.borni

Borni DHIFI
On 5/27/13, 8:38 AM

Hi,

you can overwrite all methods according to your needs.just create a new module inherit of your object .

for example :

Method create

def create(self, cr, uid, values, context=None):                
        #your treatment       
        return super(res_partner, self).create(cr, uid, values, context)

Method copy :

 def copy(self, cr, uid, id, default=None, context=None):
            if not default:
                default = {}
            #your treatment
            default.update({           
                'name': ' custom name',
            })
            return super(res_partner, self).copy(cr, uid, id, default, context=context)

Thanks.

Yes. That will work. People will find your answer useful for straight forward use. But, If I have to pass over the json result in a particular format, Just overriding the method will not help for my strange requirement I think. Because OpenERP passes the data over in json format. That is not the desired format for me. I want it to be in a different data structure. I should do that only in the osv file. Correct me if I am wrong.

Vivekrajan
on 5/27/13, 8:45 AM

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.

Register

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

0 follower(s)

Stats

Asked: 5/27/13, 7:44 AM
Seen: 2043 times
Last updated: 3/16/15, 8:10 AM