Add a "noedit" label

Registered by Juan Márquez

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,
        help="unique number of the purchase order,computed automatically when the purchase order is created",
        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.get('ir.sequence').get(cr, uid, 'purchase.order'),
    }

    _sql_constraints = [
        ('name_uniq', 'unique(name)', 'Order Reference must be unique !'),
    ]

! UPDATE ---------------------- other option ---------------------------

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

Related branches

Sprints

Whiteboard

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.