Reputation: 65
I have a field, I put it in readonly, when I click on save, the field seems empty, when I remove option readonly then it is working fine, but I need that my field to be just in readonly.
in XML:
<group col="2">
<field name="st_id" on_change="onchange_stu(st_id)/>
<field name="standard_id" readonly="1"/>
<field name="division_id" readonly="1"/>
<field name="medium_id" readonly="1"/>
</group>
Upvotes: 0
Views: 529
Reputation: 14746
When you make any field readonly="1" it will not pass to any ORM methods for the operation, it will no longer available to do such operation as it's readonly, so the purpose of that field is only to display on screen in mutable form.
However alternate solution is available in odoo app, Access readonly in ORM methods
Read-only fields are meant for informative purpose only, so they're not saved by the OpenERP client-side when persisting records, this is a known limitation.
There are many workarounds for accomplishing this (e.g. using a second invisible field to transmit the actual value), but it is probably better to avoid those cases altogether. As a rule of thumb, try to only use the read-only flag for:
It's still fine to update them via on_change calls, but don't rely on this mechanism for storing the value.
Upvotes: 1