Make fields with domain operator '=' becomes readonly.

Sent also readonly field for the creation of the record.
states attribute can not change the readonly attributes that is on the object.
This commit is contained in:
Cédric Krier committed 2008-05-29 15:50:24 +02:00
1 parent cc3ec7a0f5
commit 69a340ca81
3 files changed
+5 -1

No files matched your search

@@ -101,6 +101,8 @@ class CharField(object):
if isinstance(state_changes, basestring):
state_changes = eval(state_changes)
for key in ('readonly', 'required', 'invisible'):
if 'readonly' in self.attrs and self.attrs['readonly']:
continue
if key in state_changes:
self.get_state_attrs(model)[key] = \
eval(state_changes[key], values)
+1 -1
View File
@@ -120,7 +120,7 @@ class ModelRecord(SignalEvent):
def save(self, force_reload=True):
self._check_load()
if not self.id:
value = self.get(get_readonly=False)
value = self.get(get_readonly=True)
try:
self.id = self.rpc.create(value, self.context_get())
except Exception, exception:
@@ -297,6 +297,8 @@ class Screen(SignalEvent):
field_dom = str(fields[dom[0]].setdefault('domain',[]))
fields[dom[0]]['domain'] = field_dom[:1] + \
str(('id', dom[1], dom[2])) + ',' + field_dom[1:]
if dom[1] == '=':
fields[dom[0]]['readonly'] = True
for node in xml_dom.childNodes:
if node.localName == 'tree':
self.fields_view_tree = {'arch': arch, 'fields': fields}