Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


How to make specific field read-only after saving the record

Jagdish Panchal
on 12/11/13, 5:19 AM 1,894 views


How to make specific field read-only after saving the record? i.e. When I edit the record that field should be read-only


Ashif Abdulrahman
On 12/11/13, 5:50 AM

you have to do this one

add a boolean field in your model like

_columns = {
        'is_created' : fields.boolean('Created')

and in xml add attribute for the field to be made readonly, like,

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

and override create function in your model, like

def create(self, cr, uid, vals, context=None):
        vals['is_created'] = True
        lot = super(stock_production_lot, self).create(cr, uid, vals, context=context)
        return lot

Thanks for Ans.

Jagdish Panchal
on 12/11/13, 6:31 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)


Asked: 12/11/13, 5:19 AM
Seen: 1894 times
Last updated: 3/16/15, 8:10 AM