콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
15738 화면

Hello,

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

Thanks

아바타
취소
베스트 답변

Hello Jagdish,

> You can try this better and optimised way to make any field read only after saving a record,

> In your XML file please add 'attrs' on relevant field as below,

                 attrs="{'readonly': [('id', '!=', False)]}"


Thanks.


아바타
취소

This answer is way better

attrs no longer used since 17.0
Anyone know a way that works for 17.0?

베스트 답변

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>
</field>

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.

관련 게시물 답글 화면 활동
2
7월 25
297
1
3월 25
1145
0
11월 24
1391
1
10월 24
1444
0
6월 24
1449