Odoo Help

0

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

By
Deepak Krishna
on 10/20/15, 3:00 AM 975 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--
4060
| 5 4 7
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.--
4600
| 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

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

1 follower(s)

Stats

Asked: 10/20/15, 3:00 AM
Seen: 975 times
Last updated: 10/22/15, 1:17 PM