Field attributes in odoo

Field attributes in Odoo :

  • Attributes are the properties. Every object has some attributes. In Odoo, each model, field, etc., has some properties that are attributes. Here we will be discussing some model attributes.

1)String

2)Required

3)Help

4)Copy

5)Default

6)Invisible

7)Readonly


1)string

  • The common attributes used for every attribute.
  • By this we can set the label value of the field that is showing in GUI.
  • Example:

field_name= fields.Char(string=”Your name”)


2) required

  • This is used to take input value from user compulsory.
  • It has True and False types input.
  • Example:

field_name=fields.Char(string=”Your name”,required=True)


3) help

  • This is used to give some additional information to field name 
  • it give information in text value
  • Example:

field_name=fields.Integer(string=”Age”,help=”This is important to write”)


4) Default

  • By this we can set default value in any field
  • Example:

field_name=fields.Char(string=”Your name”,default=”Dipanshu”) 

  • So by this Dipanshu is already set in Your name field and we can edit it.


5) Copy

  • It is used to make duplicate records .
  • It has True or False in Input value and by default the value is True. 
  • So if we do not want to make a duplicate record then we can write False in it.
  • Example:

field_name=fields.Char(string=”Your name”,copy=False)


6) Readonly

  • We only can read value 
  • We can not modify the value when we give Readonly=True
  • It has True or False value. If we give True then we only read that field value.
  • Example:

​field_name=fields.Char(string=”Your name”,default=”dipanshu”,readonly=True)

  • so that we can not change this field name.


7) Invisible

  • it is used to show or hide our field name in the object
  • It also has two value : True and False
  • If we give invisible = True then the field name is hidden from the display.
  • Example:

field_name=fields.Char(string=”Your name”,invisible=True)



Administrator February 1, 2024
Share this post
Archive
Sign in to leave a comment