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
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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.
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
2
thg 7 25
|
99 | ||
|
1
thg 3 25
|
1065 | ||
|
0
thg 11 24
|
1334 | ||
|
1
thg 10 24
|
1387 | ||
|
0
thg 6 24
|
1409 |