Odoo Help

0

@api.onchange strange behavior in Odoo 8.0

By
Hesham ELMAHDY
on 1/11/15, 12:52 PM 1,205 views

I am traing convert inputs of a field into uppercase using @api.onchange

when I run this code:

`@api.onchange(product_code):

def make_uppercase(self):

    print "something ..."`

 

I get the following error:

`File "/home/hesham/odootecdev/odootec_product/odootec_product.py", line 30
    @api.onchange(product_code):
                               ^
SyntaxError: invalid syntax

`

 

if I remove the colon from the code like this:

 

`@api.onchange(product_code)

def make_uppercase(self):

    print "something ..."`

 

then I get this in the log, and it keeps looping foever till browser say `too many redirects`:

`2015-01-11 17:40:12,304 21077 INFO goboraq openerp.modules.loading: loading 1 modules...
2015-01-11 17:40:12,609 21077 INFO goboraq openerp.modules.loading: 1 modules loaded in 0.30s, 0 queries
2015-01-11 17:40:12,624 21077 INFO goboraq openerp.modules.loading: loading 31 modules...
2015-01-11 17:40:12,868 21077 INFO None werkzeug: 127.0.0.1 - - [11/Jan/2015 17:40:12] "GET /web HTTP/1.1" 302 -
2015-01-11 17:40:12,880 21077 INFO goboraq openerp.modules.loading: loading 1 modules...
2015-01-11 17:40:13,071 21077 INFO goboraq openerp.modules.loading: 1 modules loaded in 0.19s, 0 queries
2015-01-11 17:40:13,086 21077 INFO goboraq openerp.modules.loading: loading 31 modules...
2015-01-11 17:40:13,325 21077 INFO None werkzeug: 127.0.0.1 - - [11/Jan/2015 17:40:13] "GET /web HTTP/1.1" 302 -
2015-01-11 17:40:13,333 21077 INFO goboraq openerp.modules.loading: loading 1 modules...
2015-01-11 17:40:13,515 21077 INFO goboraq openerp.modules.loading: 1 modules loaded in 0.18s, 0 queries
2015-01-11 17:40:13,531 21077 INFO goboraq openerp.modules.loading: loading 31 modules...
2015-01-11 17:40:13,861 21077 INFO None werkzeug: 127.0.0.1 - - [11/Jan/2015 17:40:13] "GET /web HTTP/1.1" 302 -
2015-01-11 17:40:13,870 21077 INFO goboraq openerp.modules.loading: loading 1 modules...
2015-01-11 17:40:14,058 21077 INFO goboraq openerp.modules.loading: 1 modules loaded in 0.19s, 0 queries
2015-01-11 17:40:14,072 21077 INFO goboraq openerp.modules.loading: loading 31 modules...
2015-01-11 17:40:14,313 21077 INFO None werkzeug: 127.0.0.1 - - [11/Jan/2015 17:40:14] "GET /web HTTP/1.1" 302 -
2015-01-11 17:40:14,323 21077 INFO goboraq openerp.modules.loading: loading 1 modules...
2015-01-11 17:40:14,512 21077 INFO goboraq openerp.modules.loading: 1 modules loaded in 0.19s, 0 queries
2015-01-11 17:40:14,526 21077 INFO goboraq openerp.modules.loading: loading 31 modules...
2015-01-11 17:40:14,774 21077 INFO None werkzeug: 127.0.0.1 - - [11/Jan/2015 17:40:14] "GET /web HTTP/1.1" 302 -
2015-01-11 17:40:14,785 21077 INFO goboraq openerp.modules.loading: loading 1 modules...
2015-01-11 17:40:15,071 21077 INFO goboraq openerp.modules.loading: 1 modules loaded in 0.29s, 0 queries
2015-01-11 17:40:15,086 21077 INFO goboraq openerp.modules.loading: loading 31 modules...
2015-01-11 17:40:15,328 21077 INFO None werkzeug: 127.0.0.1 - - [11/Jan/2015 17:40:15] "GET /web HTTP/1.1" 302 -

`

Any clue?

question edited.. sorry please read again

Hesham ELMAHDY
on 1/11/15, 2:33 PM

Thanks for the people who answer, but I edited the question, please read again

Hesham ELMAHDY
on 1/11/15, 2:36 PM
1

Do the following:

@api.onchange('product_code')
def make_uppercase(self):
    print "something"

Hope this helps !!.

Thanks you. That is what I did. but gives the looping error

Hesham ELMAHDY
on 1/11/15, 2:38 PM

Did you tried copy & paste of my code. Still I can see that you not put "single quote" around the field "product_code" in @api.onchange line. This code definitely works.

Emipro Technologies Pvt. Ltd.
on 1/11/15, 11:42 PM
Perfect. Thank you so much for being patient.

On Mon, Jan 12, 2015 at 7:42 AM, Emipro Technologies Pvt. Ltd. <erp@emiprotechnologies.com> wrote:

Did you tried copy & paste of my code. Still I can see that you not put "single quote" around the field "product_code" in @api.onchange line. This code definitely works.

Emipro Technologies is best in Odoo & eCommerce Application development based outsourcing software firm. We deliver any kind of complex solutions in the domain of Odoo and eCommerce to customers accross the globe. Being in IT business since 2011, We have a strong team of skilled experienced IT experts.Our customers are companies of all sizes ranging from startups to large enterprises who realize that they need a professional internet solution to generate revenue streams, establish communication channels or streamline business operations.

Our Services in Odoo includes,
  • Installation
  • Customization
  • Configuration
  • Software Training
  • After Sale Support
  • Maintenance
  • Consulting
Contact info@emiprotechnologies.com for any kind of queries in Odoo. Visit www.emiprotechnologies.com for more details.




 

Sent by Odoo S.A. using Odoo about Forum Post False



--

Regards,

Hesham ELMAHDY
OdooTec, Techno-functional Advisor

Hesham ELMAHDY
on 1/12/15, 5:52 AM
2
Akhil P Sivan
On 1/11/15, 2:22 PM

Hi Hesham, the error occured because as shown the syntax is wrong. No need to put colon after @api.onchange(). Also the field name should be in quotes.

Thanks you. That is what I did. but gives the looping error

Hesham ELMAHDY
on 1/11/15, 2:38 PM
0
Hesham ELMAHDY
On 1/11/15, 2:40 PM

Someone with a priviledge, please delete this question. i will re-post it

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: 1/11/15, 12:52 PM
Seen: 1205 times
Last updated: 3/16/15, 8:10 AM