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 calling custom method python on xml rpc

By
Wendra
on 11/20/16, 11:22 PM 155 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

Thanks!

0

Axel Mendoza

--Axel Mendoza--
10318
| 7 7 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 an 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 

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/20/16, 11:22 PM
Seen: 155 times
Last updated: 11/21/16, 2:44 AM