Community mailing list archives

Re: xml-rpc / call custom function

Camptocamp France SAS, Alexandre Fayolle - Camptocamp
- 04/21/2015 03:02:07
On 20/04/2015 22:57, V. Imsand wrote:
<blockquote cite="" type="cite">

Hi Community,

I’m trying to call a custom function from xml-rcp

this is my simple class and arg in my module
class mytest(osv.osv):
    def div(self, x, y):
        return x // y
uid = common.authenticate(db, username, password, {})
models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))

models.execute_kw(db, uid, password, 'mytest', 'div', '')

In this example I receive a error which is normal as I haven’t defined x and y in the call

models.execute_kw(db, uid, password, 'mytest', 'div', '‘) => what’s the correct format do address x and y in my example? I have testet a couple of different ways.. but didn’t find a solution

As you may see, I’m a rookie in python but need to find a solution… may someone can help ;-(

Thanks & Regards,

Post to:

methods exposed to xml-rpc must have the following prototype: f(self, cr, uid, ..., context=None)

the ellipsis can be filled in with additional positional and / or keyword arguments. Often the 3rd argument after uid is a list of record ids.

So in your case, make this:

def div(self, cr, uid, x, y, context=None):
    return x // y

Alexandre Fayolle
Chef de Projet
Tel : + 33 (0)4 79 26 57 94

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac Cedex