Search code examples
odooodoo-8odoo-10odoo-9

odoo make field readonly when not empty


I have this field

<field name="date" />

and

date = fields.Date('Order Date')

How to make it readonly and can not be edited when there is value in it?


Solution

  • <field name="date" attrs="{'readonly': [('date', '!=', False)]}" />
    

    That should be enough.