Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
4324 Zobrazení

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?

Avatar
Zrušit
Autor

question edited.. sorry please read again

Autor

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

Nejlepší odpověď

Do the following:

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

Hope this helps !!.

Avatar
Zrušit
Autor

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

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.

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

Nejlepší odpověď

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.

Avatar
Zrušit
Autor

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

Autor Nejlepší odpověď

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
kvě 17
4345
1
bře 15
5324
1
říj 23
1928
2
říj 23
2147
2
srp 23
4126