Akhil Mathew
Akhil Mathew

Reputation: 1659

How to make a field editable only after saving the record in ODOO

I have a field in odoo. I want it to be non-editable during the creation of record. After saving the record, if we again edit it , then it should be editable

Upvotes: 1

Views: 2335

Answers (1)

Kenly
Kenly

Reputation: 26768

You can do it with readonly attribute base on id field:

<field name='id' invisible='True'/>
<field name="field_name" attrs="{'readonly': [('id','=', False )]}"/>

Demo:

<record model="ir.ui.view" id="session_form_view">
    <field name="name">session.form</field>
    <field name="model">openacademy.session</field>
    <field name="arch" type="xml">
        <form string="Session Form">
           <field name='id' invisible='True'/>
           <field name="name" attrs="{'readonly': [('id','=', False )]}"/>
        </form>
    </field>
</record>

id is a default field in odoo and it takes a value after creation of the record so name field should not be editable during creation of the record.

Upvotes: 3

Related Questions