[FIX] validation system: the last things

bzr revid: rim@openerp.com-20140409144224-6b00mnmihe8t1ii7
This commit is contained in:
Richard Mathot (OpenERP) 2014-04-09 16:42:24 +02:00
parent 6d99ca2a1f
commit 76621a0b24
1 changed files with 4 additions and 0 deletions

View File

@ -767,6 +767,7 @@ class survey_question(osv.Model):
if question.constr_mandatory:
lines_number = len(question.labels_ids_2)
answer_candidates = dict_keys_startswith(post, answer_tag)
comment_answer = answer_candidates.pop(("%s_%s" % (answer_tag, 'comment')), '').strip()
# Number of lines that have been answered
if question.matrix_subtype == 'simple':
answer_number = len(answer_candidates)
@ -774,6 +775,9 @@ class survey_question(osv.Model):
answer_number = len(set([sk.rsplit('_', 1)[0] for sk in answer_candidates.keys()]))
else:
raise RuntimeError("Invalid matrix subtype")
# Validate that each line has been answered
if answer_number != lines_number:
errors.update({answer_tag: question.constr_error_msg})
return errors