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

how to visible a tab while clicking a button , the button condition where , available = true and approved = false


i need the python function and xml code 

Avatar
Discard
Best Answer

Hi,

You can do this by using a boolean field.

Python

class className(models.Model):
_name = "model name"
test = fields.Boolean(string="Test", default=False)

def button_action(self):
self.test = True
.....
Your code
.....
Here test is the boolean field and it is set to False by default.Inside the button clicking function it is set to True.

XML

< record id="..." model="" rel="ugc">ir.ui.view">
     < field name="name">name
     < field name="model">model name
     < field name="arch" type="xml">
        < form>
          < header>
             < button string="Button Name" attrs="{'invisible': ['&', ('approved', '=', False), ('available', '=', True)]}  class="oe_highlight" name="button_action" type="object"/>
          < sheet>
            .......
            more code
            .......            < notebook attrs="{'invisible': [('test', '=', False)]}">
               < page string="Page name">
                   ............
                   more code
                   ............
               < /page>
            < /notebook>
          < /sheet>
        < /form>
     < /record>


Here condition checked for displaying the page,that is it will shown only when the test boolean field is True(This condition will set upon button click),otherwise it will be invisible.

Regards

Avatar
Discard