Help

0

How to make a field readonly and not editable after save.

Avatar
wizardz

Hello community,

How can I make a field readonly after save? It should not be editable after all.

I have try that with this, but it's not working at all.

product_reff = fields.Many2one('product.template', 'product_id', select=True)
is_created = fields.Boolean('Created')
def create(self, cr, uid, vals, context=None):
 vals['gio_is_created'] = True
 lot = super(stock_production_lot, self).create(cr, uid, vals, context=context)
 return lot


<field name="product_reff" position="attributes">
 <attribute name="attrs">{'readonly': [('is_created','=',True)]}</attribute>
 </field>


Thank you

2 Komentar
Avatar
Discard
Avatar
behnam
-

the answer dose not working for me, dose your problem solved?

Avatar
Sehrish
-
1 Jawaban
1
Avatar
Hilar AK
Best Answer

hi,

<field name="product_reff" position="attributes"> <attribute name="attrs">{'readonly': [('is_created','=',True)]}</attribute>  </field>

this should works I think is is_created has a true value.

just try this also

<xpath expr='//field[@name='product_ref']' position='attributes'>

     <attribute name='attrs'>

        {'readonly': [('is_created','=',True)]}

    </attribute>

</xpath>

Avatar
Discard