Record.get_eval must return only loaded values and validate only fields

Domain inversion should not have fields that are not loaded otherwise the
inversion could be wrong.

issue2865
review583003
(transplanted from 4d2bd7127a51862ab1293e8cdc4cf9f8bf217945)
This commit is contained in:
Cédric Krier committed 2012-11-15 18:50:16 +01:00
1 parent 82dd460c54
commit 0501cf57e5
2 files changed
+5 -3

No files matched your search

+2 -2
View File
@@ -53,11 +53,11 @@ def eval_leaf(part, context, boolop=operator.and_):
# In the case where the leaf concerns a m2o then having a value in the
# evaluation context is deemed suffisant
return bool(context.get(field.split('.')[0]))
if operand == '=' and not context[field] and boolop == operator.and_:
if operand == '=' and not context.get(field) and boolop == operator.and_:
# We should consider that other domain inversion will set a correct
# value to this field
return True
context_field = context[field]
context_field = context.get(field)
if isinstance(context_field, datetime.date) and not value:
if isinstance(context_field, datetime.datetime):
value = datetime.datetime.min
+3 -1
View File
@@ -249,6 +249,8 @@ class Record(SignalEvent):
self._check_load()
value = {}
for name, field in self.group.fields.iteritems():
if name not in self._loaded and self.id >= 0:
continue
value[name] = field.get_eval(self, check_load=check_load)
value['id'] = self.id
return value
@@ -448,7 +450,7 @@ class Record(SignalEvent):
else:
for field in fields:
self[field]
self.validate([])
self.validate(fields or [])
def expr_eval(self, expr, check_load=False):
if not isinstance(expr, basestring):