Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to add value in text box using click of button in odoo-9

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.34k
    Comment on it

    In odoo-9 first we have to create the three fields in .py file and then add two fields and store it in third fields to click the button to help the get_total function. Then pass get_total function in button.

    Use this point show in below:

    1- In .py file use this code show in below

     class Feedback(models.Model):
        _name = "feedback"   
    
        name1 = fields.Integer(string="Subject")
        name2 = fields.Integer(string="Description")
        total = fields.Integer(string="total")
       
        @api.multi
        @api.depends('name1','name2')
        def get_total(self):
            self.total = self.name1 + self.name2
            print"======self.total==========",self.total
        
    
    Feedback()

     

    2- In .xml file use this below code

    <?xml version="1.0"?>
    <openerp>
    <data>
    
    <record id="view_nursery_form77" model="ir.ui.view">
                <field name="name">view.feedback.form</field>
                <field name="model">feedback</field>
                <field name="arch" type="xml">
                    <form string="Feedback">
                        <group>
                            <field name="name1" />
                            <field name="name2" />
                            <field name="total" />
                            <button type="object" name="get_total"   string="Calculate Total"/>
                        </group>
                    </form>
                </field>
            </record>
    
    <record id="action_nursery33" model="ir.actions.act_window">
                <field name="name">Feedback</field>
                <field name="type">ir.actions.act_window</field>
                <field name="res_model">feedback</field>
                <field name="view_mode">tree,form</field>
            </record>
    
    
        <menuitem name="nursery" id="menu_student"/>
        <menuitem name="nursery" id="menu_nursery_item" parent="menu_student" action="action_nursery"/>
       <menuitem name="nursery create" id="menu_nursery_item" parent="menu_student" action="action_nursery33"/>
    
    </data>
    </openerp>
      

     

    Output:

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: