[IMP]survey : Improve warning message, set align of Professional Development Objectives separator and fix the trace back of create New Survey -> edit survey or -> test survey

bzr revid: mma@tinyerp.com-20121011093646-b8lg30yc7d4xzvdo
This commit is contained in:
Mayur Maheshwari (OpenERP) 2012-10-11 15:06:46 +05:30
parent fc94df2af5
commit 607cbf63cf
3 changed files with 34 additions and 9 deletions

View File

@ -163,10 +163,14 @@ class survey(osv.osv):
'context': context
}
def test_survey(self, cr, uid, ids, context=None):
sur_obj = self.read(cr, uid, ids,['title'], context=context)
sur_obj = self.read(cr, uid, ids,['title','page_ids'], context=context)
for sur in sur_obj:
name = sur['title']
context.update({'active':True,'survey_id': ids[0]})
pages = sur['page_ids']
if not pages:
raise osv.except_osv(_('Warning!'), _('This survey has no question defined. Please define the questions and answers first.'))
else:
context.update({'active':False,'survey_id': ids[0]})
return {
'view_type': 'form',
'view_mode': 'form',
@ -176,6 +180,26 @@ class survey(osv.osv):
'name': name,
'context': context
}
def edit_survey(self, cr, uid, ids, context=None):
sur_obj = self.read(cr, uid, ids,['title','page_ids'], context=context)
for sur in sur_obj:
name = sur['title']
pages = sur['page_ids']
if not pages:
raise osv.except_osv(_('Warning!'), _('This survey has no question defined. Please define the questions and answers first.'))
else:
context.update({'survey_id': ids[0]})
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'survey.question.wiz',
'type': 'ir.actions.act_window',
'target': 'new',
'name': name,
'context': context
}
survey()
class survey_history(osv.osv):
@ -383,7 +407,7 @@ class survey_question(osv.osv):
def write(self, cr, uid, ids, vals, context=None):
questions = self.read(cr,uid, ids, ['answer_choice_ids', 'type', 'required_type',\
'req_ans', 'minimum_req_ans', 'maximum_req_ans', 'column_heading_ids'])
'req_ans', 'minimum_req_ans', 'maximum_req_ans', 'column_heading_ids', 'page_id', 'question'])
for question in questions:
col_len = len(question['column_heading_ids'])
if vals.has_key('column_heading_ids'):
@ -401,7 +425,7 @@ class survey_question(osv.osv):
if que_type in ['matrix_of_choices_only_one_ans', 'matrix_of_choices_only_multi_ans',\
'matrix_of_drop_down_menus', 'rating_scale']:
if not col_len:
raise osv.except_osv(_('Warning!'),_("You must enter one or more column headings."))
raise osv.except_osv(_('Warning!'),_("You must enter one or more column headings for question %s of page %s.") % (question['question'], question['page_id'][1]))
ans_len = len(question['answer_choice_ids'])
if vals.has_key('answer_choice_ids'):
@ -413,7 +437,7 @@ class survey_question(osv.osv):
if que_type not in ['descriptive_text', 'single_textbox', 'comment','table']:
if not ans_len:
raise osv.except_osv(_('Warning!'),_("You must enter one or more Answers."))
raise osv.except_osv(_('Warning!'),_("You must enter one or more Answers for question %s of page %s.") % (question['question'], question['page_id'][1]))
req_type = ""
if vals.has_key('required_type'):
@ -484,11 +508,11 @@ class survey_question(osv.osv):
maximum_ans = 0
if vals.has_key('answer_choice_ids') and not len(vals['answer_choice_ids']):
if vals.has_key('type') and vals['type'] not in ['descriptive_text', 'single_textbox', 'comment','table']:
raise osv.except_osv(_('Warning!'),_("You must enter one or more answers."))
raise osv.except_osv(_('Warning!'),_("You must enter one or more answers for question %s.") % (vals['question']))
if vals.has_key('column_heading_ids') and not len(vals['column_heading_ids']):
if vals.has_key('type') and vals['type'] in ['matrix_of_choices_only_one_ans', 'matrix_of_choices_only_multi_ans', 'matrix_of_drop_down_menus', 'rating_scale']:
raise osv.except_osv(_('Warning!'),_("You must enter one or more column heading."))
raise osv.except_osv(_('Warning!'),_("You must enter one or more column heading for question %s.")% (vals['question']))
if vals['type'] in ['multiple_choice_multiple_ans','matrix_of_choices_only_one_ans', 'matrix_of_choices_only_multi_ans', 'matrix_of_drop_down_menus', 'rating_scale','multiple_textboxes','numerical_textboxes','date','date_and_time']:
if vals.has_key('is_require_answer') and vals.has_key('required_type') and vals['required_type'] in ['at least', 'at most', 'exactly']:

View File

@ -31,8 +31,8 @@
<button name="test_survey" states="open,draft,close,cancel" string="Test Survey" type="object" icon="gtk-new" context="{'survey_id': active_id}" attrs="{'invisible':[('id','=',0)]}"/>
<button name="fill_survey" states="open" string="Answer Survey" type="object" icon="gtk-execute" context="{'survey_id': active_id}" attrs="{'invisible':[('state','!=','open')]}"/>
<button name="action_print_survey" states="open,draft,close,cancel" string="Print Answer" type="object"/>
<button name="%(action_view_survey_question_message)d" states="open,draft,close,cancel"
string="Edit Survey" type="action" context="{'active':True,'edit' : True,'survey_id': active_id}"/>
<button name="edit_survey" states="open,draft,close,cancel"
string="Edit Survey" type="object" context="{'active':True,'edit' : True,'survey_id': active_id}"/>
</div>
<div class="oe_title">

View File

@ -198,6 +198,7 @@ class survey_question_wiz(osv.osv_memory):
etree.SubElement(xml_group1, 'button', {'string':'','icon': "gtk-edit", 'type' :'object', 'name':"action_edit_question", 'context' : tools.ustr(context)})
etree.SubElement(xml_group1, 'button', {'string':'','icon': "gtk-delete", 'type' :'object','name':"action_delete_question", 'context' : tools.ustr(context)})
else:
etree.SubElement(xml_form, 'newline')
etree.SubElement(xml_form, 'separator', {'string': star+to_xml(separator_string)})
ans_ids = que_rec.answer_choice_ids