Odoo Help


how to calling custom method python on xml rpc

on 11/20/16, 11:22 PM 2,881 views

Hi how to calling custom method python on odoo on xml rpc from android code example my method like this

def _get_salesteam_filter(self,user_id):
    job_id = self.env['hr.employee'].search([('user_id', '=', user_id)]).job_id.id
    sequence = self.env['sales_report_custom.sales_team_filter'].search([['job', '=', job_id]]).sequence
    filters = self.env['sales_report_custom.sales_team_filter'].search([['sequence', '>=', sequence]])

when i call my method on xml rpc, i have error like this

TypeError: get_salesteam_filter_mobile() takes exactly 2 arguments (1 given)

i put 2 parameter (self, user_id) on my android code

List data = Arrays.asList(new HashMap() {{ put("self",false); put("user_id",uid); }});


but still error, Do you have an idea ?

my guess, self parameter is not recognized


Michael Mugge
On 10/26/17, 3:32 PM

I am having this issue as well. XML-RPC is very limited. So as a work around you want to keep in mind that Odoo still supports the basic MVC paradigm.  Knowing this, I just created a controller with a little custom code to run the raw query I need and then just call that controller route from my external script (with authentication of course)

It seems to me that XML-RPC is great for the basics but at some point if you are going to start doing more advanced things, you probably just want to develop your own specific function in one or more controllers under a logical route for this purpose, such "/api' .. for example.


Axel Mendoza

--Axel Mendoza--
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza
On 11/21/16, 2:44 AM

Hi Wendra

There are a couple of things in your code

1- You cannot call methods where the method name is prefixed by _ because those are like private or internal methods and Odoo check specifically for that before calling your method, so you are not calling the right method in your xmlrpc call, you are calling get_salesteam_filter_mobile and not _get_salesteam_filter who is the one that receive the user_id parameter

2- Your method for be able to be called needs a decorator responsibly for wear it with the api environment variables like db cursor and context. This decorator could be @api.multi or @api.one if your method is defined in the res.users model to no even need to define the user_id parameter because it will be bind it to self as a browse recordset, or @api.model for arbitrary data parameter like user_id for any other model distinct from res.user

3- You don't need to pass the value of self for your xmlrpc call since self is an automatic parameter for object class methods referring to the current object and also as I said before used by Odoo to bind recordsets and many other environment stuffs 

Hope this helps 

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.


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

1 follower(s)


Asked: 11/20/16, 11:22 PM
Seen: 2881 times
Last updated: 10/26/17, 3:32 PM