Skip to Content
Menu
This question has been flagged
1 Reply
1315 Views

Hello, I want to add a textbox on the button click in my odoo v15 form view any anyone has any idea how can I achieve this?

Avatar
Discard
Best Answer

HI,

First we need add following fields in your python file:

text_active = fields.Boolean()
description = fields.Text(string='description')

then need to add these field in the xml file, make the visibility of Text field is based on Boolean field and make Boolean field in invisible :

<field name="text_active" invisible ="1"/>


<field name="description" attrs="{'invisible':[('text_active','=',False)]}"/>

In xml file we need to add button in

tag:

    <form>


      <header>


        <button name='button_to_visible' class="oe_highlight" type="object" string="button"/>


    </header>


   </form>

then after we need to define the button function in the python file:

    def button_to_visible(self):
self.text_active = True

Regards

Avatar
Discard