[IMP]:survey,crm_hr,hr_evaluation.(Ref-YSA,APA)

-Rename Defination into Definition.
-When you click on test, answer or edit survey, remove the first screen with the selection box to select the survey.
-Add survey Types in demo data: Human Resources, Customer Feeback, Supplier Selection.
-In search view of surveys, remove the vertical separator between draft and open buttons, for type field set widget=selection.
-The button for responsible=my in the search view must be default="1".
-change demo data so that some surveys belongs to admin and some to demo user.
-The browse Response report must be renamed into "Print Answers".
-Browse the answer in the screen instead of printing a PDF.
-In the history one2many, first put the date and then the user.
-I started a survey but did not finished it. so that's normal but I was not able to restart the survey (it says I already answered).
-Removed the "Que: " prefix in each report.

bzr revid: apa@tinyerp.com-20100223093223-vwhgkn8kmdo8e6mo
This commit is contained in:
apa-tiny
2010-02-23 15:02:23 +05:30
parent 95bb907bd8
commit 111d3563b0
11 changed files with 228 additions and 77 deletions
+2
View File
@@ -82,6 +82,8 @@
<field name="state">draft</field>
<field name="max_response_limit">20</field>
<field eval="[(6,0,[])]" name="users"/>
<field name="type" ref="survey.survey_type1"/>
<field name="responsible_id" ref="base.user_root"/>
</record>
</data>
<data>
@@ -5,6 +5,8 @@
<field name="title">Employee Evaluation</field>
<field name="max_response_limit">20</field>
<field eval="[(6,0,[])]" name="users"/>
<field name="type" ref="survey.survey_type1"/>
<field name="responsible_id" ref="base.user_demo"/>
</record>
</data>
<data>
@@ -12,6 +14,8 @@
<field name="title">Employee Opinion</field>
<field name="max_response_limit">20</field>
<field eval="[(6,0,[])]" name="users"/>
<field name="type" ref="survey.survey_type1"/>
<field name="responsible_id" ref="base.user_root"/>
</record>
</data>
<data>
@@ -137,7 +137,7 @@ class survey_analysis(report_rml):
for que in page.question_ids:
rml +="""<blockTable colWidths="500" style="Table5">
<tr>
<td><para style="question">Que : """ + to_xml(tools.ustr(que.question)) + """</para></td>
<td><para style="question">""" + to_xml(tools.ustr(que.question)) + """</para></td>
</tr>
</blockTable>"""
cols_widhts = []
@@ -203,7 +203,7 @@ class survey_browse_response(report_rml):
<td><para style="terp_tblheader_General_Centre_simple">""" + to_xml(time.strftime('%d-%m-%Y %I:%M:%S %p', time.strptime(response.date_create.split('.')[0], '%Y-%m-%d %H:%M:%S'))) + """</para></td>
<td><para style="terp_tblheader_General_Centre"></para></td>
<td><para style="terp_tblheader_General_right">Response By:- </para></td>
<td><para style="terp_tblheader_General_right_simple">""" + to_xml(response.user_id.name) + """</para></td>
<td><para style="terp_tblheader_General_right_simple">""" + to_xml(response.user_id.login) + """</para></td>
</tr>
</blockTable><para style="P2"></para>"""
status = "Not Finished"
@@ -232,7 +232,7 @@ class survey_browse_response(report_rml):
for que in page.question_ids:
rml += """<para style="P2"></para>
<blockTable colWidths='""" + str(_tbl_widths) + """' style="Table5">
<tr><td><para style="question">Que : """ + to_xml(to_xml(que.question)) + """</para></td></tr>
<tr><td><para style="question">""" + to_xml(to_xml(que.question)) + """</para></td></tr>
</blockTable>"""
answer = surv_resp_line_obj.browse(cr ,uid, surv_resp_line_obj.search(cr, uid, [('question_id', '=', que.id),('response_id', '=', response.id)]))
if que.type in ['descriptive_text']:
+1 -1
View File
@@ -174,7 +174,7 @@ class survey_form(report_rml):
rml +="""
<para style="P2"><font></font></para>
<blockTable colWidths='"""+_tbl_widths+"""' style="question_tbl">
<tr><td><para style="question">Que : """ + to_xml(tools.ustr(que.question)) + """</para></td></tr>
<tr><td><para style="question">""" + to_xml(tools.ustr(que.question)) + """</para></td></tr>
</blockTable>
<para style="P2"><font></font></para>"""
if que.type in ['descriptive_text']:
+148 -52
View File
@@ -49,7 +49,6 @@ class survey(osv.osv):
def default_get(self, cr, uid, fields, context={}):
data = super(survey, self).default_get(cr, uid, fields, context)
data['responsible_id'] = uid
return data
_columns = {
@@ -68,7 +67,7 @@ class survey(osv.osv):
'history' : fields.one2many('survey.history', 'survey_id', 'History Lines', readonly=True),
'users': fields.many2many('res.users', 'survey_users_rel', 'sid', 'uid', 'Users'),
'send_response' : fields.boolean('E-mail Notification on Response'),
'type' : fields.many2one('survey.type', 'Type')
'type' : fields.many2one('survey.type', 'Type'),
}
_defaults = {
'state' : lambda * a: "draft",
@@ -97,6 +96,7 @@ class survey(osv.osv):
def copy(self, cr, uid, id, default=None,context={}):
raise osv.except_osv(_('Error !'),_('You cannot duplicate the resource!'))
survey()
class survey_history(osv.osv):
@@ -177,7 +177,6 @@ class survey_question(osv.osv):
for id in ids1:
val[id] = 0
return val
_columns = {
'page_id' : fields.many2one('survey.page', 'Survey Page', ondelete='cascade', required=1),
'question' : fields.char('Question', size=128, required=1),
@@ -519,6 +518,7 @@ class survey_response(osv.osv):
'state' : lambda * a: "skip",
'response_type' : lambda * a: "manually",
}
def copy(self, cr, uid, id, default=None,context={}):
raise osv.except_osv(_('Error !'),_('You cannot duplicate the resource!'))
@@ -577,6 +577,8 @@ class survey_name_wiz(osv.osv_memory):
_name = 'survey.name.wiz'
def default_get(self, cr, uid, fields, context={}):
if not context:
context = {}
data = super(survey_name_wiz, self).default_get(cr, uid, fields, context)
if context.has_key('survey_id'):
data['survey_id'] = context['survey_id']
@@ -620,20 +622,16 @@ class survey_name_wiz(osv.osv_memory):
sur_id = self.read(cr, uid, ids, [])[0]
survey_id = sur_id['survey_id']
context.update({'survey_id' : survey_id, 'sur_name_id' : sur_id['id']})
if not context.has_key('active'):
cr.execute('select count(id) from survey_history where user_id=%s\
and survey_id=%s' % (uid,survey_id))
res = cr.fetchone()[0]
user_limit = self.pool.get('survey').read(cr, uid, survey_id, ['response_user'])['response_user']
if user_limit and res >= user_limit:
raise osv.except_osv(_('Warning !'),_("You can not give response for this survey more than %s times") % (user_limit))
his_id = self.pool.get('survey.history').create(cr, uid, {'user_id': uid, \
'date': strftime('%Y-%m-%d %H:%M:%S'), 'survey_id': survey_id})
survey_obj = self.pool.get('survey')
sur_rec = survey_obj.read(cr,uid,self.read(cr,uid,ids)[0]['survey_id'])
if sur_rec['max_response_limit'] and sur_rec['max_response_limit'] <= sur_rec['tot_start_survey']:
raise osv.except_osv(_('Warning !'),_("You can not give more response. Please contact the author of this survey for further assistance."))
survey_obj.write(cr, uid, survey_id, {'tot_start_survey' : sur_rec['tot_start_survey'] + 1})
cr.execute('select count(id) from survey_history where user_id=%s\
and survey_id=%s' % (uid,survey_id))
res = cr.fetchone()[0]
user_limit = self.pool.get('survey').read(cr, uid, survey_id, ['response_user'])['response_user']
if user_limit and res >= user_limit:
raise osv.except_osv(_('Warning !'),_("You can not give response for this survey more than %s times") % (user_limit))
survey_obj = self.pool.get('survey')
sur_rec = survey_obj.read(cr,uid,self.read(cr,uid,ids)[0]['survey_id'])
if sur_rec['max_response_limit'] and sur_rec['max_response_limit'] <= sur_rec['tot_start_survey']:
raise osv.except_osv(_('Warning !'),_("You can not give more response. Please contact the author of this survey for further assistance."))
search_obj = self.pool.get('ir.ui.view')
search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),('name','=','Survey Search')])
return {
@@ -662,7 +660,15 @@ class survey_question_wiz(osv.osv_memory):
result = super(survey_question_wiz, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu)
surv_name_wiz = self.pool.get('survey.name.wiz')
if view_type in ['form']:
sur_name_rec = surv_name_wiz.read(cr, uid, context['sur_name_id'])
wiz_id = 0
if not context.has_key('sur_name_id'):
wiz_id = surv_name_wiz.create(cr,uid, {'survey_id' : context['survey_id'],'page_no' :-1,'page':'next','transfer' :1,'response':0})
sur_name_rec = surv_name_wiz.read(cr, uid, wiz_id, [])
context.update({'sur_name_id' :wiz_id})
else:
sur_name_rec = surv_name_wiz.read(cr, uid, context['sur_name_id'])
if context.has_key('active_id'): context.pop('active_id')
survey_id = context['survey_id']
survey_obj = self.pool.get('survey')
sur_rec = survey_obj.read(cr, uid, survey_id, [])
@@ -674,6 +680,9 @@ class survey_question_wiz(osv.osv_memory):
p_id = sur_rec['page_ids']
total_pages = len(p_id)
pre_button = False
readonly = 0
if context.has_key('response_id'):
readonly = 1
if not sur_name_rec['page_no'] + 1 :
surv_name_wiz.write(cr, uid, [context['sur_name_id']], {'store_ans':{}})
sur_name_read = surv_name_wiz.read(cr, uid, context['sur_name_id'])
@@ -681,6 +690,7 @@ class survey_question_wiz(osv.osv_memory):
if sur_name_read['transfer'] or not sur_name_rec['page_no'] + 1:
surv_name_wiz.write(cr, uid, [context['sur_name_id']], {'transfer':False})
flag = False
fields = {}
if sur_name_read['page'] == "next" or sur_name_rec['page_no'] == - 1 :
if len(p_id) > sur_name_rec['page_no'] + 1 :
if sur_rec['max_response_limit'] and sur_rec['max_response_limit'] <= sur_rec['tot_start_survey'] and not sur_name_rec['page_no'] + 1:
@@ -700,10 +710,13 @@ class survey_question_wiz(osv.osv_memory):
if sur_name_rec['page_no'] > 1:
pre_button = True
if flag:
fields = {}
pag_rec = page_obj.read(cr, uid, p_id)
xml_form = etree.Element('form', {'string': _(tools.ustr(pag_rec['title']))})
xml_group = etree.SubElement(xml_form, 'group', {'col': '1', 'colspan': '4'})
if wiz_id:
fields["wizardid_" + str(wiz_id)] = {'type':'char', 'size' : 255, 'string':"", 'views':{}}
etree.SubElement(xml_form, 'field', {'invisible':'1','name': "wizardid_" + str(wiz_id),'default':str(lambda *a: 0)})
if pag_rec['note']:
for que_test in pag_rec['note'].split('\n'):
etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(que_test)), 'align':"0.0"})
@@ -736,12 +749,12 @@ class survey_question_wiz(osv.osv_memory):
for ans in ans_ids:
selection.append((tools.ustr(ans['id']), ans['answer']))
xml_group = etree.SubElement(xml_group, 'group', {'col': '2', 'colspan': '2'})
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_selection"})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_selection"})
fields[tools.ustr(que) + "_selection"] = {'type':'selection', 'selection' :selection, 'string':"Answer"}
elif que_rec['type'] == 'multiple_choice_multiple_ans':
xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'})
for ans in ans_ids:
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_" + tools.ustr(ans['id'])})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_" + tools.ustr(ans['id'])})
fields[tools.ustr(que) + "_" + tools.ustr(ans['id'])] = {'type':'boolean', 'string':ans['answer']}
elif que_rec['type'] in ['matrix_of_choices_only_one_ans', 'rating_scale']:
if que_rec['comment_column']:
@@ -753,14 +766,14 @@ class survey_question_wiz(osv.osv_memory):
xml_group = etree.SubElement(xml_group, 'group', {'col': tools.ustr(col), 'colspan': tools.ustr(colspan)})
for row in ans_ids:
etree.SubElement(xml_group, 'newline')
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_selection_" + tools.ustr(row['id']),'string':to_xml(tools.ustr(row['answer']))})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_selection_" + tools.ustr(row['id']),'string':to_xml(tools.ustr(row['answer']))})
selection = [('','')]
for col in que_col_head.read(cr, uid, que_rec['column_heading_ids']):
selection.append((str(col['id']), col['title']))
fields[tools.ustr(que) + "_selection_" + tools.ustr(row['id'])] = {'type':'selection', 'selection' : selection, 'string': "Answer"}
if que_rec['comment_column']:
fields[tools.ustr(que) + "_commentcolumn_"+tools.ustr(row['id']) + "_field"] = {'type':'char', 'size' : 255, 'string':tools.ustr(que_rec['column_name']), 'views':{}}
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_commentcolumn_"+tools.ustr(row['id'])+ "_field"})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_commentcolumn_"+tools.ustr(row['id'])+ "_field"})
elif que_rec['type'] == 'matrix_of_choices_only_multi_ans':
xml_group = etree.SubElement(xml_group, 'group', {'col': str(len(que_rec['column_heading_ids']) + 1), 'colspan': '4'})
etree.SubElement(xml_group, 'separator', {'string': '.','colspan': '1'})
@@ -769,7 +782,7 @@ class survey_question_wiz(osv.osv_memory):
for row in ans_ids:
etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(row['answer'])) +' :-', 'align': '0.0'})
for col in que_col_head.read(cr, uid, que_rec['column_heading_ids']):
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['id']), 'nolabel':"1"})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['id']), 'nolabel':"1"})
fields[tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['id'])] = {'type':'boolean', 'string': col['title']}
elif que_rec['type'] == 'matrix_of_drop_down_menus':
xml_group = etree.SubElement(xml_group, 'group', {'col': str(len(que_rec['column_heading_ids']) + 1), 'colspan': '4'})
@@ -783,7 +796,7 @@ class survey_question_wiz(osv.osv_memory):
if col['menu_choice']:
for item in col['menu_choice'].split('\n'):
if item and not item.strip() == '': selection.append((item ,item))
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['id']),'nolabel':'1'})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['id']),'nolabel':'1'})
fields[tools.ustr(que) + "_" + tools.ustr(row['id']) + "_" + tools.ustr(col['id'])] = {'type':'selection', 'string': col['title'], 'selection':selection}
elif que_rec['type'] == 'multiple_textboxes':
xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'})
@@ -796,7 +809,7 @@ class survey_question_wiz(osv.osv_memory):
elif que_rec['validation_type'] in ['must_be_date']:
type = "date"
for ans in ans_ids:
etree.SubElement(xml_group, 'field', {'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"})
if type == "char" :
fields[tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"] = {'type':'char', 'size':255, 'string':ans['answer']}
else:
@@ -804,26 +817,26 @@ class survey_question_wiz(osv.osv_memory):
elif que_rec['type'] == 'numerical_textboxes':
xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'})
for ans in ans_ids:
etree.SubElement(xml_group, 'field', {'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_numeric"})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_numeric"})
fields[tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_numeric"] = {'type':'integer', 'string':ans['answer']}
elif que_rec['type'] == 'date':
xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'})
for ans in ans_ids:
etree.SubElement(xml_group, 'field', {'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id'])})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id'])})
fields[tools.ustr(que) + "_" + tools.ustr(ans['id'])] = {'type':'date', 'string':ans['answer']}
elif que_rec['type'] == 'date_and_time':
xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'})
for ans in ans_ids:
etree.SubElement(xml_group, 'field', {'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id'])})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id'])})
fields[tools.ustr(que) + "_" + tools.ustr(ans['id'])] = {'type':'datetime', 'string':ans['answer']}
elif que_rec['type'] == 'descriptive_text':
for que_test in que_rec['descriptive_text'].split('\n'):
etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(que_test)), 'align':"0.0"})
elif que_rec['type'] == 'single_textbox':
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_single", 'nolabel':"1" ,'colspan':"4"})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_single", 'nolabel':"1" ,'colspan':"4"})
fields[tools.ustr(que) + "_single"] = {'type':'char', 'size' : 255, 'string':"single_textbox", 'views':{}}
elif que_rec['type'] == 'comment':
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_comment", 'nolabel':"1" ,'colspan':"4"})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_comment", 'nolabel':"1" ,'colspan':"4"})
fields[tools.ustr(que) + "_comment"] = {'type':'text', 'string':"Comment/Eassy Box", 'views':{}}
elif que_rec['type'] == 'table':
xml_group = etree.SubElement(xml_group, 'group', {'col': str(len(que_rec['column_heading_ids'])), 'colspan': '4'})
@@ -831,16 +844,16 @@ class survey_question_wiz(osv.osv_memory):
etree.SubElement(xml_group, 'separator', {'string': tools.ustr(col['title']),'colspan': '1'})
for row in range(0,que_rec['no_of_rows']):
for col in que_col_head.read(cr, uid, que_rec['column_heading_ids']):
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_table_" + tools.ustr(col['id']) +"_"+ tools.ustr(row), 'nolabel':"1"})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_table_" + tools.ustr(col['id']) +"_"+ tools.ustr(row), 'nolabel':"1"})
fields[tools.ustr(que) + "_table_" + tools.ustr(col['id']) +"_"+ tools.ustr(row)] = {'type':'char','size':255,'views':{}}
elif que_rec['type'] == 'multiple_textboxes_diff_type':
xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'})
for ans in ans_ids:
if ans['type'] == "email" :
fields[tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"] = {'type':'char', 'size':255, 'string':ans['answer']}
etree.SubElement(xml_group, 'field', {'widget':'email','width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'widget':'email','width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"})
else:
etree.SubElement(xml_group, 'field', {'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'width':"300",'colspan': '1','name': tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"})
if ans['type'] == "char" :
fields[tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"] = {'type':'char', 'size':255, 'string':ans['answer']}
elif ans['type'] in ['integer','float','date','datetime']:
@@ -853,22 +866,22 @@ class survey_question_wiz(osv.osv_memory):
fields[tools.ustr(que) + "_" + tools.ustr(ans['id']) + "_multi"] = {'type':'selection', 'selection' : selection, 'string':ans['answer']}
if que_rec['type'] in ['multiple_choice_only_one_ans', 'multiple_choice_multiple_ans', 'matrix_of_choices_only_one_ans', 'matrix_of_choices_only_multi_ans', 'matrix_of_drop_down_menus', 'rating_scale'] and que_rec['is_comment_require']:
if que_rec['type'] in ['multiple_choice_only_one_ans', 'multiple_choice_multiple_ans'] and que_rec['comment_field_type'] in ['char','text'] and que_rec['make_comment_field']:
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_otherfield", 'colspan':"4"})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_otherfield", 'colspan':"4"})
fields[tools.ustr(que) + "_otherfield"] = {'type':'boolean', 'string':que_rec['comment_label'], 'views':{}}
if que_rec['comment_field_type'] == 'char':
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_other", 'nolabel':"1" ,'colspan':"4"})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_other", 'nolabel':"1" ,'colspan':"4"})
fields[tools.ustr(que) + "_other"] = {'type': 'char', 'string': '', 'size':255, 'views':{}}
elif que_rec['comment_field_type'] == 'text':
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_other", 'nolabel':"1" ,'colspan':"4"})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_other", 'nolabel':"1" ,'colspan':"4"})
fields[tools.ustr(que) + "_other"] = {'type': 'text', 'string': '', 'views':{}}
else:
if que_rec['comment_field_type'] == 'char':
etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(que_rec['comment_label'])),'colspan':"4"})
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_other", 'nolabel':"1" ,'colspan':"4"})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_other", 'nolabel':"1" ,'colspan':"4"})
fields[tools.ustr(que) + "_other"] = {'type': 'char', 'string': '', 'size':255, 'views':{}}
elif que_rec['comment_field_type'] == 'text':
etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(que_rec['comment_label'])),'colspan':"4"})
etree.SubElement(xml_group, 'field', {'name': tools.ustr(que) + "_other", 'nolabel':"1" ,'colspan':"4"})
etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que) + "_other", 'nolabel':"1" ,'colspan':"4"})
fields[tools.ustr(que) + "_other"] = {'type': 'text', 'string': '', 'views':{}}
etree.SubElement(xml_form, 'separator', {'colspan': '4'})
xml_group = etree.SubElement(xml_form, 'group', {'col': '6', 'colspan': '4'})
@@ -878,7 +891,7 @@ class survey_question_wiz(osv.osv_memory):
etree.SubElement(xml_group, 'button', {'icon': "gtk-cancel", 'special': "cancel",'string':"Cancel"})
if pre_button:
etree.SubElement(xml_group, 'button', {'colspan':"1",'icon':"gtk-go-back",'name':"action_previous",'string':"Previous",'type':"object"})
etree.SubElement(xml_group, 'button', {'icon': "gtk-go-forward", 'name':"action_next",'string':"Next",'type':"object"})
etree.SubElement(xml_group, 'button', {'icon': "gtk-go-forward", 'name':"action_next",'string':"Next",'type':"object",'context' : tools.ustr(context)})
if context.has_key('active') and context.has_key('edit'):
etree.SubElement(xml_form, 'separator', {'string' : '','colspan': '4'})
context.update({'page_id' : tools.ustr(p_id),'page_number' : sur_name_rec['page_no'] , 'transfer' : sur_name_read['transfer']})
@@ -959,15 +972,54 @@ class survey_question_wiz(osv.osv_memory):
tot_page_id = self.pool.get('survey').browse(cr, uid, context['survey_id'])
tot_per = (float(100) * (int(field.split('_')[2]) + 1) / len(tot_page_id.page_ids))
value[field] = tot_per
if context.has_key('active') and context['active']:
return value
surv_name_wiz = self.pool.get('survey.name.wiz')
sur_name_read = surv_name_wiz.read(cr, uid, context['sur_name_id'])
ans_list = []
for key,val in sur_name_read['store_ans'].items():
for field in fields_list:
if field in list(val):
value[field] = val[field]
if context.has_key('response_id'):
response_obj = self.pool.get('survey.response')
response_ans = response_obj.browse(cr, uid, context['response_id'])
fields_list.sort()
for que in response_ans.question_ids:
for field in fields_list:
if field.split('_')[0] != "progress" and field.split('_')[0] == str(que.question_id.id):
if que.response_answer_ids and len(field.split('_')) == 4 and field.split('_')[1] == "commentcolumn" and field.split('_')[3] == "field":
for ans in que.response_answer_ids:
if str(field.split('_')[2]) == str(ans.answer_id.id):
value[field] = ans.comment_field
if que.response_table_ids and len(field.split('_')) == 4 and field.split('_')[1] == "table":
for ans in que.response_table_ids:
if str(field.split('_')[2]) == str(ans.column_id.id) and str(field.split('_')[3]) == str(ans.name):
value[field] = ans.value
if que.comment and (field.split('_')[1] == "comment" or field.split('_')[1] == "other"):
value[field] = str(que.comment)
elif que.single_text and field.split('_')[1] == "single":
value[field] = str(que.single_text)
elif que.response_answer_ids and len(field.split('_')) == 3 and field.split('_')[1] == "selection":
for ans in que.response_answer_ids:
if str(field.split('_')[2]) == str( ans.answer_id.id):
value[field] = str(ans.column_id.id)
elif que.response_answer_ids and len(field.split('_')) == 2 and field.split('_')[1] == "selection":
value[field] = str(que.response_answer_ids[0].answer_id.id)
elif que.response_answer_ids and len(field.split('_')) == 3 and field.split('_')[2] != "multi" and field.split('_')[2] != "numeric":
for ans in que.response_answer_ids:
if str(field.split('_')[1]) == str( ans.answer_id.id) and str(field.split('_')[2]) == str(ans.column_id.id):
if ans.value_choice:
value[field] = ans.value_choice
else:
value[field] = True
else:
for ans in que.response_answer_ids:
if str(field.split('_')[1]) == str( ans.answer_id.id):
value[field] = ans.answer
else:
if not context.has_key('sur_name_id'):
return value
if context.has_key('active') and context['active']:
return value
surv_name_wiz = self.pool.get('survey.name.wiz')
sur_name_read = surv_name_wiz.read(cr, uid, context['sur_name_id'])
ans_list = []
for key,val in sur_name_read['store_ans'].items():
for field in fields_list:
if field in list(val):
value[field] = val[field]
return value
def create(self, cr, uid, vals, context=None):
@@ -976,13 +1028,15 @@ class survey_question_wiz(osv.osv_memory):
for key,val in vals.items():
if key.split('_')[0] == "progress":
vals.pop(key)
break
if not context.has_key('sur_name_id') and key.split('_')[0] == "wizardid":
context.update({'sur_name_id': int(key.split('_')[1])})
vals.pop(key)
click_state = True
click_update = []
surv_name_wiz = self.pool.get('survey.name.wiz')
surv_all_resp_obj = self.pool.get('survey.response')
surv_tbl_column_obj = self.pool.get('survey.tbl.column.heading')
sur_name_read = surv_name_wiz.read(cr, uid, context['sur_name_id'])
sur_name_read = surv_name_wiz.read(cr, uid, context['sur_name_id'], [])
response_id = 0
if not sur_name_read['response']:
response_id = surv_all_resp_obj.create(cr, uid, {'response_type':'link', 'user_id':uid, 'date_create':datetime.datetime.now(), 'survey_id' : context['survey_id']})
@@ -992,6 +1046,13 @@ class survey_question_wiz(osv.osv_memory):
if response_id not in surv_all_resp_obj.search(cr, uid, []):
response_id = surv_all_resp_obj.create(cr, uid, {'response_type':'link', 'user_id':uid, 'date_create':datetime.datetime.now(), 'survey_id' : context['survey_id']})
surv_name_wiz.write(cr, uid, [context['sur_name_id']], {'response' : tools.ustr(response_id)})
#click first time on next button then increemnet on total start suvey
if not sur_name_read['store_ans']:
his_id = self.pool.get('survey.history').create(cr, uid, {'user_id': uid, \
'date': strftime('%Y-%m-%d %H:%M:%S'), 'survey_id': sur_name_read['survey_id']})
survey_obj = self.pool.get('survey')
sur_rec = survey_obj.read(cr, uid, sur_name_read['survey_id'])
survey_obj.write(cr, uid, sur_name_read['survey_id'], {'tot_start_survey' : sur_rec['tot_start_survey'] + 1})
for key,val in sur_name_read['store_ans'].items():
for field in vals:
if field.split('_')[0] == val['question_id']:
@@ -1530,4 +1591,39 @@ class survey_request(osv.osv):
survey_request()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
class survey_print_answer(osv.osv_memory):
_name = 'survey.print.answer'
def _get_survey(self, cr, uid, context=None):
surv_obj = self.pool.get("survey")
surv_resp_obj = self.pool.get("survey.response")
result = []
for sur in surv_obj.browse(cr, uid, surv_obj.search(cr, uid, [])):
if surv_resp_obj.search(cr, uid, [('survey_id', '=', sur.id)]):
result.append((sur.id, sur.title))
return result
_columns = {
'survey_id': fields.selection(_get_survey, "Survey", required="1"),
'response_id': fields.many2one("survey.response", "Survey Response", required="1"),
}
def action_next(self, cr, uid, ids, context=None):
response_id = self.read(cr, uid, ids, [])[0]
context.update({'active' : True,'survey_id' : response_id['survey_id'], 'response_id' : response_id['response_id']})
search_obj = self.pool.get('ir.ui.view')
search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),('name','=','Survey Search')])
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'survey.question.wiz',
'type': 'ir.actions.act_window',
'target': 'new',
'search_view_id':search_id[0],
'context' : context
}
survey_print_answer()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+20 -6
View File
@@ -2,12 +2,25 @@
<openerp>
<data noupdate="1">
<record model="survey.type" id="survey_type1">
<field name="name">Human Resources</field>
<field name="code">Human Resources</field>
</record>
<record model="survey.type" id="survey_type2">
<field name="name">Customer Feeback</field>
<field name="code">Customer Feeback</field>
</record>
<record model="survey.type" id="survey_type3">
<field name="name">Supplier Selection</field>
<field name="code">Supplier Selection</field>
</record>
<!-- Partner Feedback Demo data -->
<record model="survey" id="survey_partner_feedback">
<field name="title">Open ERP Partner Feedback</field>
<field name="user_id" ref="base.user_root"/>
<field name="question_prefix">Que</field>
<field name="responsible_id" ref="base.user_root"/>
<field name="max_response_limit">20</field>
<field name="type" ref="survey_type2"/>
</record>
<record id="survey_page_who_are_you" model="survey.page">
@@ -476,9 +489,9 @@
<!-- Partner Feedback Demo data -->
<record model="survey" id="survey_odoo_feedback">
<field name="title">Odoo Feedback</field>
<field name="question_prefix">Que</field>
<field name="user_id" ref="base.user_root"/>
<field name="responsible_id" ref="base.user_demo"/>
<field name="max_response_limit">20</field>
<field name="type" ref="survey_type2"/>
</record>
<record id="survey_page_odoo_who_are_you" model="survey.page">
@@ -1264,9 +1277,9 @@
<data>
<record id="survey_0" model="survey">
<field eval="&quot;&quot;&quot;OpenERP Feedback&quot;&quot;&quot;" name="title"/>
<field name="user_id" ref="base.user_root"/>
<field name="question_prefix">Que</field>
<field name="responsible_id" ref="base.user_demo"/>
<field name="max_response_limit">20</field>
<field name="type" ref="survey_type2"/>
</record>
</data>
<data>
@@ -2143,6 +2156,7 @@
<field name="responsible_id" ref="base.user_root"/>
<field eval="1" name="send_response"/>
<field eval="[(6,0,[])]" name="users"/>
<field name="type" ref="survey_type3"/>
</record>
</data>
<data>
+32
View File
@@ -77,6 +77,38 @@
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<!--
Browse Response Wizard (Survey print answer)
-->
<record id="view_survey_answer" model="ir.ui.view">
<field name="name">Survey</field>
<field name="model">survey.print.answer</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Survey">
<separator colspan="4" string = "Select Survey and related response"/>
<field name="survey_id" width="250"/>
<field name="response_id" domain="[('survey_id','=', survey_id)]"/>
<separator colspan="4" />
<label align="0.0" colspan="2" string="" />
<button colspan="1" icon="gtk-cancel" special="cancel" string="Cancel"/>
<button colspan="1" icon="gtk-go-forward" name="action_next" string="Start" type="object"/>
</form>
</field>
</record>
<record id="action_browse_survey_response"
model="ir.actions.act_window">
<field name="name">Answer Survey Response</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">survey.print.answer</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>
+1 -1
View File
@@ -17,6 +17,6 @@
<report auto="True" id="survey_browse_response" model="survey"
name="survey.browse.response"
rml=""
string="Browse Response"/>
string="Print Answers"/>
</data>
</openerp>
+16 -12
View File
@@ -7,7 +7,7 @@
<menuitem name="Survey" id="main_menu_survey"
sequence="3" groups="group_survey_manager,group_survey_user"
parent="base.menu_tools" />
<menuitem id="menu_defination" name="Defination" parent="main_menu_survey" sequence="1"/>
<menuitem id="menu_defination" name="Definition" parent="main_menu_survey" sequence="1" groups="group_survey_manager"/>
<!-- <menuitem name="Configuration" id="menu_survey_config" parent="main_menu_survey" groups="group_survey_manager"/>-->
<menuitem name="Configuration" parent="base.menu_tools"
id="base.menu_lunch_survey_root" groups="group_survey_manager" sequence="6"/>
@@ -25,11 +25,12 @@
<field name="title" select="1"/>
<group col="6" colspan="6">
<field name="responsible_id"/>
<button name="%(action_view_survey_name)d" states="open,draft,close,cancel"
string="Test Survey" type="action" icon="gtk-new" context="{'active':True,'survey_id': active_id}"/>
<button name="%(action_view_survey_name)d" states="open,draft,close,cancel"
<button name="%(action_view_survey_question_message)d" states="open,draft,close,cancel"
string="Test Survey" type="action" icon="gtk-new"
context="{'active':True,'survey_id': active_id}"/>
<button name="%(action_view_survey_question_message)d" states="open,draft,close,cancel"
string="Answer Survey" type="action" icon="gtk-execute" context="{'survey_id': active_id}" attrs="{'readonly':[('state','!=','open')]}"/>
<button name="%(action_view_survey_name)d" states="open,draft,close,cancel"
<button name="%(action_view_survey_question_message)d" states="open,draft,close,cancel"
string="Edit Survey" type="action" icon="gtk-edit" context="{'active':True,'edit' : True,'survey_id': active_id}"/>
</group>
<notebook colspan="4">
@@ -210,12 +211,12 @@
<field name="tot_comp_survey" select="1"/>
<field name="history" colspan="4" nolabel="1">
<tree string="History">
<field name="user_id"/>
<field name="date"/>
<field name="user_id"/>
</tree>
<form string="History">
<field name="user_id"/>
<field name="date"/>
<field name="user_id"/>
</form>
</field>
</page>
@@ -237,7 +238,7 @@
<field name="tot_start_survey" select="2" string="Started"/>
<field name="tot_comp_survey" select="2" string="Completed"/>
<field name="state" select="1"/>
<button name="%(action_view_survey_name)d" states="open,draft,close,cancel"
<button name="%(action_view_survey_question_message)d" states="open,draft,close,cancel"
string="Test Survey" type="action" icon="gtk-execute" context="{'active':True,'survey_id': active_id}"/>
<button name="%(action_view_survey_name)d" states="open,draft,close,cancel"
string="Answer Survey" type="action" icon="gtk-new" context="{'survey_id': active_id}"/>
@@ -257,12 +258,11 @@
<search string="Search Survey">
<group col='10' colspan='4'>
<filter icon="terp-crm" string="Draft" domain="[('state','=','draft')]"/>
<separator orientation="vertical"/>
<filter string="Open" icon="terp-stock" domain="[('state','=','open')]"/>
<separator orientation="vertical"/>
<field name="title" select="1"/>
<field name="type" select="1"/>
<field name="responsible_id" select="1" widget="selection">
<field name="type" select="1" widget="selection"/>
<field name="responsible_id" select="1" widget="selection" default="1">
<filter string="MY" icon="terp-partner" domain="[('responsible_id','=',uid)]"/>
</field>
</group>
@@ -1119,8 +1119,12 @@
action="action_view_survey_name" parent="main_menu_survey"
groups="group_survey_manager,group_survey_user" icon="STOCK_INDEX"/>
<menuitem name="Browse Response" id="menu_browse_survey_response"
action="action_browse_survey_response" parent="main_menu_survey"
groups="group_survey_manager" icon="STOCK_PRINT_PREVIEW"/>
<menuitem action="wizard_browse_answer" id="menu_wizard_browse_answer"
parent="main_menu_survey" type="wizard" groups="group_survey_manager"/>
parent="main_menu_survey" type="wizard" icon="STOCK_PRINT" groups="group_survey_manager"/>
</data>
</openerp>
+1 -2
View File
@@ -8,8 +8,7 @@
<wizard string="Print Survey" id="wizard_print_survey"
model="survey" name="wizard.print.survey"/>
<wizard string="Browse Answer" id="wizard_browse_answer"
<wizard string="Print Answers" id="wizard_browse_answer"
model="survey.response" name="wizard.browse.answer"/>
</data>
</openerp>