do not ignore value if equal to default on saving, but only in check on empty row

This commit is contained in:
Helmut Merz 2014-01-19 10:47:21 +01:00
parent 9977e8b191
commit d4d7a47b09

View file

@ -1,5 +1,5 @@
# #
# Copyright (c) 2013 Helmut Merz helmutm@cy55.de # Copyright (c) 2014 Helmut Merz helmutm@cy55.de
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -122,6 +122,8 @@ class GridFieldInstance(ListFieldInstance):
def unmarshallRow(self, row, idx=None): def unmarshallRow(self, row, idx=None):
item = {} item = {}
cardinality = getattr(self.context, 'cardinality', None) cardinality = getattr(self.context, 'cardinality', None)
ignoreInCheckOnEmpty = list(
getattr(self.context, 'ignoreInCheckOnEmpty', []))
for fi in self.columnFieldInstances: for fi in self.columnFieldInstances:
if idx is not None: if idx is not None:
fi.index = idx fi.index = idx
@ -133,10 +135,9 @@ class GridFieldInstance(ListFieldInstance):
else: else:
if fi.default is not None: if fi.default is not None:
if value == fi.default: if value == fi.default:
continue ignoreInCheckOnEmpty.append(fi.name)
if value: if value:
item[fi.name] = value item[fi.name] = value
ignoreInCheckOnEmpty = getattr(self.context, 'ignoreInCheckOnEmpty', [])
for k, v in item.items(): for k, v in item.items():
if k not in ignoreInCheckOnEmpty: #and v != '__no_change__': if k not in ignoreInCheckOnEmpty: #and v != '__no_change__':
return item return item