calculation with submulti

This commit is contained in:
Emmanuel Garette 2021-03-18 08:57:22 +01:00
parent b76db42204
commit af2d3eb3ce
1 changed files with 15 additions and 5 deletions

View File

@ -69,11 +69,21 @@ class Leadership(OptionDescription):
child.impl_get_display_name()))
if idx != 0:
default = child.impl_getdefault()
if default != [] and not isinstance(default, Calculation):
raise ValueError(_('not allowed default value for follower option "{0}" '
'in leadership "{1}"'
'').format(child.impl_get_display_name(),
self.impl_get_display_name()))
if default != []:
if child.impl_is_submulti() and isinstance(default, tuple):
for val in default:
if not isinstance(val, Calculation):
calculation = False
else:
# empty default is valid
calculation = True
else:
calculation = isinstance(default, Calculation)
if not calculation:
raise ValueError(_('not allowed default value for follower option "{0}" '
'in leadership "{1}"'
'').format(child.impl_get_display_name(),
self.impl_get_display_name()))
if idx != 0:
# remove empty property for follower
child._properties = frozenset(child._properties - {'empty', 'unique'})