Skip to Content
Menu
This question has been flagged
2 Replies
7616 Views

I am trying to keep validation for boolean field. In this field only one field in the table can true, if one field gets checked true (checked for default stage) then remaining fields should get false.

xml:

<record id="in_stage_field_Form_view" model="ir.ui.view">

         <field name="name">Stage</field>

         <field name="model">inventory.stages</field>

          <field name="view_type">form</field>

         <field name="view_mode">form</field>

         <field name="arch" type="xml">

           <form >

               <sheet>

                   <group>

                       <field name="name" required="True"/>

                       <field name="default_stage" />

                   </group>

               </sheet>

           </form>

         </field>

       </record>


py:

class inventory_stages(models.Model):

    _name = "inventory.stages"


    name = fields.Char ()

    default_stage = fields.Boolean ("Default Stage")


Here i want to keep validation for default_Stage field.

Avatar
Discard
Best Answer

Hi,
You can add validation like this,


@api.constrains('default_stage')
def check_validation(self):
#write condition to validate

Avatar
Discard

Thank you this worked

Related Posts Replies Views Activity
1
Mar 15
2897
2
Jun 23
1117
1
Nov 19
3891
3
Aug 18
8007
1
Jul 17
13172