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 get value from input tag in python ?

By
Łukasz Szczesiak
on 9/16/15, 9:16 AM 1,660 views

How to get value from input tag in python ? I've created input tag with id and name, but whatever i try to get it in python( tried self.tag_id or self.tag_name ) i get error that object like this does not exist.

Below code of my xml.

	<record model="ir.ui.view" id="training_test_form_view">
<field name="name">Training Test Form View</field>
<field name="model">training.test_online</field>
<field name="priority" eval="5"/>
<field name="arch" type="xml">
<form string="Training Form" create="false"
delete="false">
<sheet>
<field name="question" nolabel="1" readonly="1"/>
<group>
<input id="cliked_1" name="answer" type="radio"> <field name="answer1" nolabel="1" readonly="1"/></input>
<input id="cliked_2" name="answer" type="radio"> <field name="answer2" nolabel="1" readonly="1"/></input>
<input id="cliked_3" name="answer" type="radio"> <field name="answer3" nolabel="1" readonly="1"/></input>
<input id="cliked_4" name="answer" type="radio"> <field name="answer4" nolabel="1" readonly="1"/></input>
</group>

<button name="next" type="object" />
</sheet>
</form>
</field>
</record>

and exmaple code in python which is giving error

 @api.one  
 def next(self):
print self.clicked1


Do i need to get it by self, context, js, or how ?

5

Parikshit

--Parikshit--
939
| 6 3 8
Ahmedabad, India
--Parikshit--

Working as an OpenERP/Odoo developer both experience in web and addons. you can contact me at:

E-mail : parikshitvaghasiya@gmail.com

Blog : parikshitvaghasiya.blogspot.in

Stackoverflow : http://stackoverflow.com/users/5089106/parikshit-vaghasiya

Parikshit
On 9/16/15, 9:35 AM

Hello,
For this you have to code in js and from js you have to pass data in python method and also call python method from there like this:
First give button id in xml : (id = "next")

openerp.module_name = function(instance) {

    var QWeb = openerp.web.qweb;
        _t = instance.web._t;
    
    instance.web.View.include({
        load_view: function(context) {
            var self = this;
            var view_loaded_def;
            if ($('#next').length == 1){     $('#next').click({
              //here you can code for get value of form and also call python method and pass value.
                    console.log('your value......',$('#cliked_1').value());
                });
            } return self._super(context); }, }); }


hope this will help you !!

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: 9/16/15, 9:16 AM
Seen: 1660 times
Last updated: 9/16/15, 9:37 AM