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

Whether onchange() function in odoo 8 requires classical arguments (cr,uid,ids...) ?

By
Deepak Krishna
on 10/20/15, 3:00 AM 622 views

@api.onchange('r_sale')

def get_onchange(self):

        if self.r_sale:

                  obj=self.env['sale.order'].browse(self.r_sale)

                   print obj.id

This function showing Error : "  get_onchange() takes exactly 1 argument (5 given)".

This is how i defined on_change in view :<field name="r_sale" on_change="get_onchange(r_sale)"/>

What are the 5 arguments passed to the function get_onchange()? Why it shows error?




2

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 10/20/15, 3:15 AM

You don't need to use on_change attribute in view definition for v8. And also in browse() you need to pass list of id/ids.

Try like this:

@api.onchange('r_sale')

def _get_onchange(self):

if self.r_sale:

obj=self.env['sale.order'].browse([self.r_sale.id])

print obj.id

in view:

<field name="r_sale" />;

Thank You

Deepak Krishna
on 10/20/15, 4:08 AM
1

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4341
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 10/20/15, 3:12 AM

Hello Deepak Krishna,

If you are using api.onchange, then you don't have to specify the onchange in your xml.

Just remove the "on_change" (on_change="get_onchange(r_sale)") attribute from xml, update the module and try that again.

Hope this will help you.

Thank You

Deepak Krishna
on 10/20/15, 4:09 AM
1
Karthik Arumugam
On 10/20/15, 3:14 AM

Hi Depak

You need not to specify on_change="get_onchange(r_sale)"/> in your view definiton.

I think this may be the problem.


Thank You

Deepak Krishna
on 10/20/15, 4:08 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: 10/20/15, 3:00 AM
Seen: 622 times
Last updated: 10/22/15, 1:17 PM