Add a "noedit" label
Many models have a "reference" data field assigned to a sequence (char field: name), if I set then field as readonly the value isn't saved to database, but if I don't mark the field as readonly, the users can change the value assigned by de sequence. this is a very big error situation.
The solution (I Think) is create a new label "noedit". The fields with this label set to true are readonly but they are writed to database.
Sample code: (from purchase order)
_columns = {
'name': fields.char('Order Reference', size=64, required=True, select=True,
noedit=True ),
}
# with "noedit=True" flag the data in the view is readonly but stored in database
_defaults = {
'name': lambda obj, cr, uid, context: obj.pool.
}
_sql_
]
! UPDATE -------
Also the "store=True" label can force a readonly field to be writed to database and get the same result
Blueprint information
- Status:
- Not started
- Approver:
- None
- Priority:
- Undefined
- Drafter:
- None
- Direction:
- Needs approval
- Assignee:
- None
- Definition:
- New
- Series goal:
- None
- Implementation:
- Unknown
- Milestone target:
- None
- Started by
- Completed by