diff --git a/addons/survey/survey.py b/addons/survey/survey.py
index fdb1818bd69..79f30df1a37 100644
--- a/addons/survey/survey.py
+++ b/addons/survey/survey.py
@@ -62,7 +62,6 @@ class survey(osv.osv):
'tot_start_survey': fields.integer("Total Started Survey", readonly=1),
'tot_comp_survey': fields.integer("Total Completed Survey", readonly=1),
'note': fields.text('Description', size=128),
- 'history': fields.one2many('survey.history', 'survey_id', 'History Lines', readonly=True),
'partner_id': fields.many2many('res.partner', 'survey_partner_rel', 'sid', 'partner_id', 'Partners'),
'send_response': fields.boolean('Email Notification on Answer'),
'type': fields.many2one('survey.type', 'Type'),
@@ -95,7 +94,7 @@ class survey(osv.osv):
current_rec = self.read(cr, uid, ids, context=context)
title = _("%s (copy)") % (current_rec.get('title'))
vals.update({'title':title})
- vals.update({'history':[],'tot_start_survey':0,'tot_comp_survey':0})
+ vals.update({'tot_start_survey':0,'tot_comp_survey':0})
return super(survey, self).copy(cr, uid, ids, vals, context=context)
def action_print_survey(self, cr, uid, ids, context=None):
@@ -232,20 +231,6 @@ class survey(osv.osv):
survey()
-class survey_history(osv.osv):
- _name = 'survey.history'
- _description = 'Survey History'
- _rec_name = 'date'
- _columns = {
- 'survey_id': fields.many2one('survey', 'Survey'),
- 'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
- 'date': fields.datetime('Date started', readonly=1),
- }
- _defaults = {
- 'date': lambda * a: datetime.datetime.now()
- }
-survey_history()
-
class survey_page(osv.osv):
_name = 'survey.page'
_description = 'Survey Pages'
diff --git a/addons/survey/survey_demo.xml b/addons/survey/survey_demo.xml
index 6f89095c699..e235911bb01 100644
--- a/addons/survey/survey_demo.xml
+++ b/addons/survey/survey_demo.xml
@@ -2914,20 +2914,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/addons/survey/survey_view.xml b/addons/survey/survey_view.xml
index deb68c3d0a1..68b5cd575cb 100644
--- a/addons/survey/survey_view.xml
+++ b/addons/survey/survey_view.xml
@@ -228,16 +228,6 @@
-
-
-
-
-
-
-
diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py
index f8a4ff47f39..a6a5652ebca 100644
--- a/addons/survey/wizard/survey_answer.py
+++ b/addons/survey/wizard/survey_answer.py
@@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
+# Copyright (C) 2004-2010 Tiny SPRL ().
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -15,14 +15,11 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
+# along with this program. If not, see .
#
##############################################################################
-import base64
-import datetime
from lxml import etree
-import os
from time import strftime
from openerp import addons, netsvc, tools
@@ -32,38 +29,42 @@ from datetime import datetime
from openerp.tools.translate import _
from openerp.tools.safe_eval import safe_eval
+
class survey_question_wiz(osv.osv_memory):
_name = 'survey.question.wiz'
_columns = {
'name': fields.integer('Number'),
}
- def _view_field_multiple_choice_only_one_ans(self, xml_group, fields, readonly, que, que_rec):
+ def _view_field_multiple_choice_only_one_ans(self, cr, uid, xml_group, fields, readonly, que, que_rec):
selection = []
for ans in que_rec.answer_choice_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', {'readonly':str(readonly), 'name': tools.ustr(que.id) + "_selection"})
- fields[tools.ustr(que.id) + "_selection"] = {'type':'selection', 'selection' :selection, 'string':"Answer"}
- # TODO convert selection field into radio input
- def _view_field_multiple_choice_multiple_ans(self, xml_group, fields, readonly, que, que_rec):
+ etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'name': tools.ustr(que.id) + "_selection"})
+ fields[tools.ustr(que.id) + "_selection"] = {'type': 'selection', 'selection': selection, 'string': "Answer"}
+
+ def _view_field_multiple_choice_multiple_ans(self, cr, uid, xml_group, fields, readonly, que, que_rec):
+ # TODO convert selection field into radio input
xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'})
for ans in que_rec.answer_choice_ids:
- etree.SubElement(xml_group, 'field', {'readonly':str(readonly), 'name': tools.ustr(que.id) + "_" + tools.ustr(ans.id)})
- fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id)] = {'type':'boolean', 'string':ans.answer}
+ etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'name': tools.ustr(que.id) + "_" + tools.ustr(ans.id)})
+ fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id)] = {'type': 'boolean', 'string': ans.answer}
+
+ def _view_field_matrix_of_choices_only_multi_ans(self, cr, uid, xml_group, fields, readonly, que, que_rec):
+ que_col_head = self.pool.get('survey.question.column.heading')
- def _view_field_matrix_of_choices_only_multi_ans(self, xml_group, fields, readonly, que, que_rec):
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'})
+ etree.SubElement(xml_group, 'separator', {'string': '.', 'colspan': '1'})
for col in que_rec.column_heading_ids:
- etree.SubElement(xml_group, 'separator', {'string': tools.ustr(col.title),'colspan': '1'})
+ etree.SubElement(xml_group, 'separator', {'string': tools.ustr(col.title), 'colspan': '1'})
for row in que_rec.answer_choice_ids:
- etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(row.answer)) +' :-', 'align': '0.0'})
- for col in que_col_head.browse(cr, uid, [head.id for head in que_rec.column_heading_ids]):
- etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que.id) + "_" + tools.ustr(row.id) + "_" + tools.ustr(col.id), 'nolabel':"1"})
- fields[tools.ustr(que.id) + "_" + tools.ustr(row.id) + "_" + tools.ustr(col.id)] = {'type':'boolean', 'string': col.title}
+ etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(row.answer)) + ': -', 'align': '0.0'})
+ for col in que_col_head.browse(cr, uid, [head.id for head in que_rec.column_heading_ids]):
+ etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'name': tools.ustr(que.id) + "_" + tools.ustr(row.id) + "_" + tools.ustr(col.id), 'nolabel': "1"})
+ fields[tools.ustr(que.id) + "_" + tools.ustr(row.id) + "_" + tools.ustr(col.id)] = {'type': 'boolean', 'string': col.title}
- def _view_field_multiple_textboxes(self, xml_group, fields, readonly, que, que_rec):
+ def _view_field_multiple_textboxes(self, cr, uid, xml_group, fields, readonly, que, que_rec):
xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'})
type = "char"
if que_rec.is_validation_require:
@@ -74,96 +75,105 @@ class survey_question_wiz(osv.osv_memory):
elif que_rec.validation_type in ['must_be_date']:
type = "date"
for ans in que_rec.answer_choice_ids:
- etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'width':"300",'colspan': '1','name': tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"})
- if type == "char" :
- fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"] = {'type':'char', 'size':255, 'string':ans.answer}
- else:
- fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"] = {'type': str(type), 'string':ans.answer}
+ etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'width': "300", 'colspan': '1', 'name': tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"})
+ fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"] = {'type': str(type), 'string': ans.answer}
- def _view_field_numerical_textboxes(self, xml_group, fields, readonly, que, que_rec):
+ def _view_field_numerical_textboxes(self, cr, uid, xml_group, fields, readonly, que, que_rec):
xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'})
for ans in que_rec.answer_choice_ids:
- etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'width':"300",'colspan': '1','name': tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_numeric"})
- fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_numeric"] = {'type':'integer', 'string':ans.answer}
+ etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'width': "300", 'colspan': '1', 'name': tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_numeric"})
+ fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_numeric"] = {'type': 'integer', 'string': ans.answer}
- def _view_field_date(self, xml_group, fields, readonly, que, que_rec):
+ def _view_field_date(self, cr, uid, xml_group, fields, readonly, que, que_rec):
xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'})
for ans in que_rec.answer_choice_ids:
- etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'width':"300",'colspan': '1','name': tools.ustr(que.id) + "_" + tools.ustr(ans.id)})
- fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id)] = {'type':'date', 'string':ans.answer}
+ etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'width': "300", 'colspan': '1', 'name': tools.ustr(que.id) + "_" + tools.ustr(ans.id)})
+ fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id)] = {'type': 'date', 'string': ans.answer}
- def _view_field_date_and_time(self, xml_group, fields, readonly, que, que_rec):
+ def _view_field_date_and_time(self, cr, uid, xml_group, fields, readonly, que, que_rec):
xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'})
for ans in que_rec.answer_choice_ids:
- etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'width':"300",'colspan': '1','name': tools.ustr(que.id) + "_" + tools.ustr(ans.id)})
- fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id)] = {'type':'datetime', 'string':ans.answer}
+ etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'width': "300", 'colspan': '1', 'name': tools.ustr(que.id) + "_" + tools.ustr(ans.id)})
+ fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id)] = {'type': 'datetime', 'string': ans.answer}
- def _view_field_descriptive_text(self, xml_group, fields, readonly, que, que_rec):
+ def _view_field_descriptive_text(self, cr, uid, xml_group, fields, readonly, que, que_rec):
if que_rec.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"})
+ etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(que_test)), 'align': "0.0"})
- def _view_field_single_textbox(self, xml_group, fields, readonly, que, que_rec):
- etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que.id) + "_single", 'nolabel':"1" ,'colspan':"4"})
- fields[tools.ustr(que.id) + "_single"] = {'type':'char', 'size': 255, 'string':"single_textbox", 'views':{}}
+ def _view_field_single_textbox(self, cr, uid, xml_group, fields, readonly, que, que_rec):
+ etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'name': tools.ustr(que.id) + "_single", 'nolabel': "1", 'colspan': "4"})
+ fields[tools.ustr(que.id) + "_single"] = {'type': 'char', 'size': 255, 'string': "single_textbox", 'views': {}}
- def _view_field_comment(self, xml_group, fields, readonly, que, que_rec):
- etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que.id) + "_comment", 'nolabel':"1" ,'colspan':"4"})
- fields[tools.ustr(que.id) + "_comment"] = {'type':'text', 'string':"Comment/Eassy Box", 'views':{}}
+ def _view_field_comment(self, cr, uid, xml_group, fields, readonly, que, que_rec):
+ etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'name': tools.ustr(que.id) + "_comment", 'nolabel': "1", 'colspan': "4"})
+ fields[tools.ustr(que.id) + "_comment"] = {'type': 'text', 'string': "Comment/Eassy Box", 'views': {}}
- def _view_field_table(self, xml_group, fields, readonly, que, que_rec):
+ def _view_field_table(self, cr, uid, xml_group, fields, readonly, que, que_rec):
xml_group = etree.SubElement(xml_group, 'group', {'col': str(len(que_rec.column_heading_ids)), 'colspan': '4'})
for col in que_rec.column_heading_ids:
- etree.SubElement(xml_group, 'separator', {'string': tools.ustr(col.title),'colspan': '1'})
- for row in range(0,que_rec.no_of_rows):
+ 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_rec.column_heading_ids:
- etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que.id) + "_table_" + tools.ustr(col.id) +"_"+ tools.ustr(row), 'nolabel':"1"})
- fields[tools.ustr(que.id) + "_table_" + tools.ustr(col.id) +"_"+ tools.ustr(row)] = {'type':'char','size':255,'views':{}}
+ etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'name': tools.ustr(que.id) + "_table_" + tools.ustr(col.id) + "_" + tools.ustr(row), 'nolabel': "1"})
+ fields[tools.ustr(que.id) + "_table_" + tools.ustr(col.id) + "_" + tools.ustr(row)] = {'type': 'char', 'size': 255, 'views': {}}
- def _view_field_multiple_textboxes_diff_type(self, xml_group, fields, readonly, que, que_rec):
+ def _view_field_multiple_textboxes_diff_type(self, cr, uid, xml_group, fields, readonly, que, que_rec):
xml_group = etree.SubElement(xml_group, 'group', {'col': '4', 'colspan': '4'})
for ans in que_rec.answer_choice_ids:
- if ans.type == "email" :
- fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"] = {'type':'char', 'size':255, 'string':ans.answer}
- etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'widget':'email','width':"300",'colspan': '1','name': tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"})
+ if ans.type == "email":
+ fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"] = {'type': 'char', 'size': 255, 'string': ans.answer}
+ etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'widget': 'email', 'width': "300", 'colspan': '1', 'name': tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"})
else:
- etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'width':"300",'colspan': '1','name': tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"})
- if ans.type == "char" :
- fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"] = {'type':'char', 'size':255, 'string':ans.answer}
- elif ans.type in ['integer','float','date','datetime']:
- fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"] = {'type': str(ans.type), 'string':ans.answer}
+ etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'width': "300", 'colspan': '1', 'name': tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"})
+ if ans.type == "char":
+ fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"] = {'type': 'char', 'size': 255, 'string': ans.answer}
+ elif ans.type in ['integer', 'float', 'date', 'datetime']:
+ fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"] = {'type': str(ans.type), 'string': ans.answer}
else:
selection = []
if ans.menu_choice:
for item in ans.menu_choice.split('\n'):
- if item and not item.strip() == '': selection.append((item ,item))
- fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"] = {'type':'selection', 'selection' : selection, 'string':ans.answer}
+ if item and not item.strip() == '':
+ selection.append((item, item))
+ fields[tools.ustr(que.id) + "_" + tools.ustr(ans.id) + "_multi"] = {'type': 'selection', 'selection': selection, 'string': ans.answer}
- def _view_field_matrix_of_choices_only_one_ans(self, xml_group, fields, readonly, que, que_rec):
+ def _view_field_matrix_of_choices_only_one_ans(self, cr, uid, xml_group, fields, readonly, que, que_rec):
if que_rec.comment_column:
col = "4"
colspan = "4"
else:
- col = "2"
- colspan = "2"
+ col = "2"
+ colspan = "2"
xml_group = etree.SubElement(xml_group, 'group', {'col': tools.ustr(col), 'colspan': tools.ustr(colspan)})
for row in que_rec.answer_choice_ids:
etree.SubElement(xml_group, 'newline')
- etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'name': tools.ustr(que.id) + "_selection_" + tools.ustr(row.id),'string':to_xml(tools.ustr(row.answer))})
- selection = [('','')]
+ etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'name': tools.ustr(que.id) + "_selection_" + tools.ustr(row.id), 'string': to_xml(tools.ustr(row.answer))})
+ selection = [('', '')]
for col in que_rec.column_heading_ids:
selection.append((str(col.id), col.title))
- fields[tools.ustr(que.id) + "_selection_" + tools.ustr(row.id)] = {'type':'selection', 'selection' : selection, 'string': "Answer"}
+ fields[tools.ustr(que.id) + "_selection_" + tools.ustr(row.id)] = {'type': 'selection', 'selection': selection, 'string': "Answer"}
if que_rec.comment_column:
- fields[tools.ustr(que.id) + "_commentcolumn_"+tools.ustr(row.id) + "_field"] = {'type':'char', 'size' : 255, 'string':tools.ustr(que_rec.column_name), 'views':{}}
- etree.SubElement(xml_group, 'field', {'readonly' :str(readonly), 'name': tools.ustr(que.id) + "_commentcolumn_"+tools.ustr(row.id)+ "_field"})
+ fields[tools.ustr(que.id) + "_commentcolumn_" + tools.ustr(row.id) + "_field"] = {'type': 'char', 'size': 255, 'string': tools.ustr(que_rec.column_name), 'views': {}}
+ etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'name': tools.ustr(que.id) + "_commentcolumn_" + tools.ustr(row.id) + "_field"})
- def _view_field_rating_scale(self, xml_group, fields, readonly, que, que_rec):
+ def _view_field_rating_scale(self, cr, uid, xml_group, fields, readonly, que, que_rec):
self._view_field_matrix_of_choices_only_one_ans(xml_group, fields, readonly, que, que_rec)
- def _view_survey_complete(self, result):
+ def _view_field_after_matrix_of_choices(self, cr, uid, xml_group, fields, readonly, que, que_rec):
+ 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', {'readonly': str(readonly), 'name': tools.ustr(que.id) + "_otherfield", 'colspan': "4"})
+ fields[tools.ustr(que.id) + "_otherfield"] = {'type': 'boolean', 'string': que_rec.comment_label, 'views': {}}
+ etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'name': tools.ustr(que.id) + "_other", 'nolabel': "1", 'colspan': "4"})
+ fields[tools.ustr(que.id) + "_other"] = {'type': que_rec.comment_field_type, 'string': '', 'views': {}}
+ else:
+ etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(que_rec.comment_label)), 'colspan': "4"})
+ etree.SubElement(xml_group, 'field', {'readonly': str(readonly), 'name': tools.ustr(que.id) + "_other", 'nolabel': "1", 'colspan': "4"})
+ fields[tools.ustr(que.id) + "_other"] = {'type': que_rec.comment_field_type, 'string': '', 'views': {}}
+
+ def _view_survey_complete(self, result, context):
xml_form = etree.Element('form', {'string': _('Complete Survey Answer')})
- #xml_footer = etree.SubElement(xml_form, 'footer', {'col': '6', 'colspan': '4' ,'class': 'oe_survey_title_height'})
+ #xml_footer = etree.SubElement(xml_form, 'footer', {'col': '6', 'colspan': '4', 'class': 'oe_survey_title_height'})
etree.SubElement(xml_form, 'separator', {'string': 'Survey Completed', 'colspan': "4"})
etree.SubElement(xml_form, 'label', {'string': 'Thanks for your Answer'})
etree.SubElement(xml_form, 'newline')
@@ -171,56 +181,68 @@ class survey_question_wiz(osv.osv_memory):
result['arch'] = etree.tostring(root)
result['fields'] = {}
result['context'] = context
-
- def _survey_complete(self, survey_id, partner_id, sur_rec):
+
+ def _survey_complete(self, cr, uid, survey_id, partner_id, sur_name_read, survey_browse, context):
survey_obj = self.pool.get('survey')
sur_response_obj = self.pool.get('survey.response')
# record complete
- survey_obj.write(cr, uid, survey_id, {'tot_comp_survey' : sur_rec.tot_comp_survey + 1})
- sur_response_obj.write(cr, uid, [sur_name_read.response], {'state' : 'done'})
+ survey_obj.write(cr, uid, survey_id, {'tot_comp_survey': survey_browse.tot_comp_survey + 1})
+ sur_response_obj.write(cr, uid, [sur_name_read.response], {'state': 'done'})
# send mail to the responsible
- survey_data = survey_obj.browse(cr, uid, survey_id, context.context)
- responsible_id = survey_data.responsible_id and survey_data.responsible_id.email or False
- if sur_rec.send_response and responsible_id:
+ survey_browse = survey_obj.browse(cr, uid, survey_id, context)
+ responsible_id = survey_browse.responsible_id and survey_browse.responsible_id.id or False
+ if survey_browse.send_response and responsible_id:
val = {
'type': 'notification',
'author_id': partner_id or None,
- 'partner_ids': [responsible_id],
- 'notified_partner_ids': [responsible_id],
+ 'partner_ids': responsible_id and [responsible_id] or None,
'model': 'survey',
'res_id': survey_id,
'record_name': _("Survey N° %s") % survey_id,
- 'subject': survey_data.title,
+ 'subject': survey_browse.title or None,
'body': _("A survey answer is completed."),
}
- self.pool.get('mail.thread').create(cr, uid, val, context=context)
-
+ print val
+ self.pool.get('mail.message').create(cr, uid, val, context=context)
+
+ def _check_token(self, cr, uid, survey_id, context):
+ # get if the token of the partner or anonymous user is valid
+ survey_browse = self.pool.get('survey').browse(cr, uid, survey_id, context=context)
+
+ if survey_browse.responsible_id.id == uid:
+ response_id = False
+ partner_id = survey_browse.responsible_id.partner_id.id or False
+ else:
+ sur_response_obj = self.pool.get('survey.response')
+
+ pid = self.pool.get('res.users').browse(cr, uid, uid, context=context).partner_id.id
+ response_id = sur_response_obj.search(cr, uid, [
+ ('survey_id', '=', survey_browse.id), ('state', '=', 'new'),
+ '|', ('partner_id', '=', pid), ("token", "=", context.get("survey_token", None)),
+ '|', ('date_deadline', '=', None), ('date_deadline', '<', datetime.now())], context=context, limit=1)
+ if response_id:
+ sur_response_browse = sur_response_obj.browse(cr, uid, response_id[0], context=context)
+ partner_id = sur_response_browse.partner_id.id or False
+
+ return {'partner_id': partner_id or False, 'response_id': response_id and response_id[0] or False}
+
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
"""
- Fields View Get method :- generate the new view and display the survey pages of selected survey.
+ Fields View Get method: - generate the new view and display the survey pages of selected survey.
"""
if context is None:
context = {}
- result = super(survey_question_wiz, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu)
+ 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')
survey_obj = self.pool.get('survey')
page_obj = self.pool.get('survey.page')
que_obj = self.pool.get('survey.question')
- ans_obj = self.pool.get('survey.answer')
sur_response_obj = self.pool.get('survey.response')
- que_col_head = self.pool.get('survey.question.column.heading')
- user_obj = self.pool.get('res.users')
- user_browse = user_obj.browse(cr, uid, uid, context=context)
- #todo
- partner_id = 0
- partner_email = 'fqsdf@fdqsf'
- partner_obj = self.pool.get('res.partner')
- mail_message = self.pool.get('mail.message')
-
+
if view_type in ['form']:
wiz_id = 0
sur_name_rec = None
@@ -236,9 +258,9 @@ class survey_question_wiz(osv.osv_memory):
}
wiz_id = surv_name_wiz.create(cr, uid, res_data)
sur_name_rec = surv_name_wiz.browse(cr, uid, wiz_id, context=context)
- context.update({'sur_name_id' :wiz_id})
+ context.update({'sur_name_id': wiz_id})
- if context.has_key('active_id'):
+ if context.get('active_id'):
context.pop('active_id')
survey_id = context.get('survey_id', False)
@@ -255,52 +277,43 @@ class survey_question_wiz(osv.osv_memory):
return super(survey_question_wiz, self).\
fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context,
toolbar=toolbar, submenu=submenu)
- sur_rec = survey_obj.browse(cr, uid, survey_id, context=context)
- p_id = map(lambda x:x.id, sur_rec.page_ids)
+ survey_browse = survey_obj.browse(cr, uid, survey_id, context=context)
+ p_id = map(lambda x: x.id, survey_browse.page_ids)
total_pages = len(p_id)
pre_button = False
readonly = 0
if context.get('response_id', False) \
- and int(context['response_id'][0]) > 0:
+ and int(context['response_id'][0]) > 0:
readonly = 1
- if not sur_name_rec.page_no + 1 :
- surv_name_wiz.write(cr, uid, [context['sur_name_id'],], {'store_ans':{}})
+ 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.browse(cr, uid, context['sur_name_id'], context=context)
page_number = int(sur_name_rec.page_no)
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})
+ surv_name_wiz.write(cr, uid, [context['sur_name_id']], {'transfer': False})
flag = False
fields = {}
# get if the token of the partner or anonymous user is valid
- validate_response = sur_rec.responsible_id.id == uid or sur_response_obj.search(cr, uid, [('survey_id','=',survey_id), ('state','=','new'),
- '|', ('partner_id','=',partner_id), ("token","=", context.get("survey_token", None)),
- '|', ('date_deadline','=',None), ('date_deadline','<',datetime.now())], context=context, limit=1)
- active = context.get('active', False)
+ check_token = self._check_token(cr, uid, survey_id, context)
# have acces to this survey
- if validate_response:
+ if check_token['partner_id'] or check_token['response_id']:
+ active = context.get('active', False)
+
if sur_name_read.page == "next" or sur_name_rec.page_no == -1:
if total_pages > sur_name_rec.page_no + 1:
- if not active and not sur_name_rec.page_no + 1:
- if sur_rec.state != "open" :
- raise osv.except_osv(_('Warning!'),_("You cannot answer because the survey is not open."))
- cr.execute('select count(id) from survey_history where partner_id=%s\
- and survey_id=%s', (uid,survey_id))
- res = cr.fetchone()[0]
- partner_limit = survey_obj.browse(cr, uid, survey_id)
- partner_limit = partner_limit.response_partner
- if partner_limit and res >= partner_limit:
- raise osv.except_osv(_('Warning!'),_("You cannot answer this survey more than %s times.") % (partner_limit))
+ if not active and not sur_name_rec.page_no + 1 and survey_browse.state != "open":
+ raise osv.except_osv(_('Warning!'), _("You cannot answer because the survey is not open."))
- 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:
- survey_obj.write(cr, uid, survey_id, {'state':'close', 'date_close':strftime("%Y-%m-%d %H:%M:%S")})
+ if survey_browse.max_response_limit and survey_browse.max_response_limit <= survey_browse.tot_start_survey and not sur_name_rec.page_no + 1:
+ survey_obj.write(cr, uid, survey_id, {'state': 'close', 'date_close': strftime("%Y-%m-%d %H: %M: %S")})
p_id = p_id[sur_name_rec.page_no + 1]
- surv_name_wiz.write(cr, uid, [context['sur_name_id'],], {'page_no' : sur_name_rec.page_no + 1})
+ surv_name_wiz.write(cr, uid, [context['sur_name_id'], ], {'page_no': sur_name_rec.page_no + 1})
flag = True
page_number += 1
if sur_name_rec.page_no > - 1:
@@ -310,8 +323,8 @@ class survey_question_wiz(osv.osv_memory):
else:
if sur_name_rec.page_no != 0:
p_id = p_id[sur_name_rec.page_no - 1]
- surv_name_wiz.write(cr, uid, [context['sur_name_id'],],\
- {'page_no' : sur_name_rec.page_no - 1})
+ surv_name_wiz.write(cr, uid, [context['sur_name_id'], ], \
+ {'page_no': sur_name_rec.page_no - 1})
flag = True
page_number -= 1
@@ -321,88 +334,86 @@ class survey_question_wiz(osv.osv_memory):
# survey in progress
if flag:
pag_rec = page_obj.browse(cr, uid, p_id, context=context)
- xml_form = etree.Element('form', {'string': tools.ustr( pag_rec and pag_rec.title or sur_rec.title )})
+ xml_form = etree.Element('form', {'string': tools.ustr(pag_rec and pag_rec.title or survey_browse.title)})
if active and context.get('edit'):
- context.update({'page_id' : tools.ustr(p_id),'page_number' : sur_name_rec.page_no , 'transfer' : sur_name_read.transfer})
+ context.update({'page_id': tools.ustr(p_id), 'page_number': sur_name_rec.page_no, 'transfer': sur_name_read.transfer})
xml_group3 = etree.SubElement(xml_form, 'group', {'col': '4', 'colspan': '4'})
- etree.SubElement(xml_group3, 'button', {'string' :'Add Page','icon': "gtk-new", 'type' :'object','name':"action_new_page", 'context' : tools.ustr(context)})
- etree.SubElement(xml_group3, 'button', {'string' :'Edit Page','icon': "gtk-edit", 'type' :'object','name':"action_edit_page", 'context' : tools.ustr(context)})
- etree.SubElement(xml_group3, 'button', {'string' :'Delete Page','icon': "gtk-delete", 'type' :'object','name':"action_delete_page", 'context' : tools.ustr(context)})
- etree.SubElement(xml_group3, 'button', {'string' :'Add Question','icon': "gtk-new", 'type' :'object','name':"action_new_question", 'context' : tools.ustr(context)})
+ etree.SubElement(xml_group3, 'button', {'string': 'Add Page', 'icon': "gtk-new", 'type': 'object', 'name': "action_new_page", 'context': tools.ustr(context)})
+ etree.SubElement(xml_group3, 'button', {'string': 'Edit Page', 'icon': "gtk-edit", 'type': 'object', 'name': "action_edit_page", 'context': tools.ustr(context)})
+ etree.SubElement(xml_group3, 'button', {'string': 'Delete Page', 'icon': "gtk-delete", 'type': 'object', 'name': "action_delete_page", 'context': tools.ustr(context)})
+ etree.SubElement(xml_group3, 'button', {'string': 'Add Question', 'icon': "gtk-new", 'type': 'object', 'name': "action_new_question", 'context': tools.ustr(context)})
# FP Note
xml_group = xml_form
- if context.get('response_id') and int(context.get('response_id',0)[0]) > 0:
+ if context.get('response_id') and int(context.get('response_id', 0)[0]) > 0:
# TODO: l10n, cleanup this code to make it readable. Or template?
xml_group = etree.SubElement(xml_form, 'group', {'col': '40', 'colspan': '4'})
record = sur_response_obj.browse(cr, uid, context['response_id'][context['response_no']])
- etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr('Answer Of :- ' + record.partner_id.name + ', Date :- ' + record.date_create.split('.')[0] )), 'align':"0.0"})
- etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(" Answer :- " + str(context.get('response_no',0) + 1) +"/" + str(len(context.get('response_id',0))) )), 'align':"0.0"})
- if context.get('response_no',0) > 0:
- etree.SubElement(xml_group, 'button', {'colspan':"1",'icon':"gtk-go-back",'name':"action_forward_previous",'string': tools.ustr("Previous Answer"),'type':"object"})
- if context.get('response_no',0) + 1 < len(context.get('response_id',0)):
- etree.SubElement(xml_group, 'button', {'colspan':"1",'icon': "gtk-go-forward", 'name':"action_forward_next",'string': tools.ustr("Next Answer") ,'type':"object",'context' : tools.ustr(context)})
+ etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr('Answer Of: - ' + record.partner_id.name + ', Date: - ' + record.date_create.split('.')[0])), 'align': "0.0"})
+ etree.SubElement(xml_group, 'label', {'string': to_xml(tools.ustr(" Answer: - " + str(context.get('response_no', 0) + 1) + "/" + str(len(context.get('response_id', 0))))), 'align': "0.0"})
+ if context.get('response_no', 0) > 0:
+ etree.SubElement(xml_group, 'button', {'colspan': "1", 'icon': "gtk-go-back", 'name': "action_forward_previous", 'string': tools.ustr("Previous Answer"), 'type': "object"})
+ if context.get('response_no', 0) + 1 < len(context.get('response_id', 0)):
+ etree.SubElement(xml_group, 'button', {'colspan': "1", 'icon': "gtk-go-forward", 'name': "action_forward_next", 'string': tools.ustr("Next Answer"), 'type': "object", 'context': tools.ustr(context)})
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),'modifiers':'{"invisible":true}'})
+ 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), 'modifiers': '{"invisible": true}'})
if pag_rec and pag_rec.note:
- xml_group_note = etree.SubElement(xml_form, 'group', {'col': '1','colspan': '4'})
+ xml_group_note = etree.SubElement(xml_form, 'group', {'col': '1', 'colspan': '4'})
for que_test in pag_rec.note.split('\n'):
- etree.SubElement(xml_group_note, 'label', {'string': to_xml(tools.ustr(que_test)), 'align':"0.0"})
-
+ etree.SubElement(xml_group_note, 'label', {'string': to_xml(tools.ustr(que_test)), 'align': "0.0"})
+
qu_no = 0
for que in (pag_rec and pag_rec.question_ids or []):
qu_no += 1
que_rec = que_obj.browse(cr, uid, que.id, context=context)
- descriptive_text = ""
separator_string = tools.ustr(qu_no) + "." + tools.ustr(que_rec.question)
star = (not active and que_rec.is_require_answer) and '*' or ''
if active and context.get('edit'):
- etree.SubElement(xml_form, 'separator', {'string': star+to_xml(separator_string)})
+ etree.SubElement(xml_form, 'separator', {'string': star + to_xml(separator_string)})
xml_group1 = etree.SubElement(xml_form, 'group', {'col': '2', 'colspan': '2'})
- context.update({'question_id' : tools.ustr(que.id),'page_number': sur_name_rec.page_no , 'transfer' : sur_name_read.transfer, 'page_id' : p_id})
- 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)})
+ context.update({'question_id': tools.ustr(que.id), 'page_number': sur_name_rec.page_no, 'transfer': sur_name_read.transfer, 'page_id': p_id})
+ 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)})
+ etree.SubElement(xml_form, 'separator', {'string': star + to_xml(separator_string)})
xml_group = etree.SubElement(xml_form, 'group', {'col': '1', 'colspan': '4'})
# rendering different views
- getattr(self, "_view_field_%s" % que_rec.type)(xml_group, fields, readonly, que, que_rec)
+ getattr(self, "_view_field_%s" % que_rec.type)(cr, uid, xml_group, fields, readonly, que, que_rec)
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', 'rating_scale'] and que_rec.is_comment_require:
- self._view_field_after_matrix_of_choices(xml_group, fields, readonly, que, que_rec)
+ self._view_field_after_matrix_of_choices(cr, uid, xml_group, fields, readonly, que, que_rec)
-
- xml_footer = etree.SubElement(xml_form, 'footer', {'col': '8', 'colspan': '1', 'width':"100%"})
+ xml_footer = etree.SubElement(xml_form, 'footer', {'col': '8', 'colspan': '1', 'width': "100%"})
if pre_button:
etree.SubElement(xml_footer, 'label', {'string': ""})
- etree.SubElement(xml_footer, 'button', {'name':"action_previous",'string':"Previous",'type':"object"})
+ etree.SubElement(xml_footer, 'button', {'name': "action_previous", 'string': "Previous", 'type': "object"})
but_string = "Next"
if int(page_number) + 1 == total_pages:
but_string = "Done"
- if active and int(page_number) + 1 == total_pages and context.get('response_id') and context.get('response_no',0) + 1 == len(context.get('response_id',0)):
+ if active and int(page_number) + 1 == total_pages and context.get('response_id') and context.get('response_no', 0) + 1 == len(context.get('response_id', 0)):
etree.SubElement(xml_footer, 'label', {'string': ""})
- etree.SubElement(xml_footer, 'button', {'special' : 'cancel','string': tools.ustr("Done") ,'context' : tools.ustr(context), 'class':"oe_highlight"})
+ etree.SubElement(xml_footer, 'button', {'special': 'cancel', 'string': tools.ustr("Done"), 'context': tools.ustr(context), 'class': "oe_highlight"})
elif active and int(page_number) + 1 == total_pages and context.get('response_id'):
etree.SubElement(xml_footer, 'label', {'string': ""})
- etree.SubElement(xml_footer, 'button', {'name':"action_forward_next",'string': tools.ustr("Next Answer") ,'type':"object",'context' : tools.ustr(context), 'class':"oe_highlight"})
+ etree.SubElement(xml_footer, 'button', {'name': "action_forward_next", 'string': tools.ustr("Next Answer"), 'type': "object", 'context': tools.ustr(context), 'class': "oe_highlight"})
elif active and int(page_number) + 1 == total_pages:
etree.SubElement(xml_footer, 'label', {'string': ""})
- etree.SubElement(xml_footer, 'button', {'special': "cancel", 'string' : 'Done', 'context' : tools.ustr(context), 'class':"oe_highlight"})
+ etree.SubElement(xml_footer, 'button', {'special': "cancel", 'string': 'Done', 'context': tools.ustr(context), 'class': "oe_highlight"})
else:
etree.SubElement(xml_footer, 'label', {'string': ""})
- etree.SubElement(xml_footer, 'button', {'name':"action_next",'string': tools.ustr(but_string) ,'type':"object",'context' : tools.ustr(context), 'class':"oe_highlight"})
+ etree.SubElement(xml_footer, 'button', {'name': "action_next", 'string': tools.ustr(but_string), 'type': "object", 'context': tools.ustr(context), 'class': "oe_highlight"})
if context.get('ir_actions_act_window_target', None):
etree.SubElement(xml_footer, 'label', {'string': "or"})
- etree.SubElement(xml_footer, 'button', {'special': "cancel",'string':"Exit",'class':"oe_link"})
- etree.SubElement(xml_footer, 'label', {'string': tools.ustr(page_number+ 1) + "/" + tools.ustr(total_pages), 'class':"oe_survey_title_page oe_right"})
+ etree.SubElement(xml_footer, 'button', {'special': "cancel", 'string': "Exit", 'class': "oe_link"})
+ etree.SubElement(xml_footer, 'label', {'string': tools.ustr(page_number + 1) + "/" + tools.ustr(total_pages), 'class': "oe_survey_title_page oe_right"})
root = xml_form.getroottree()
result['arch'] = etree.tostring(root)
@@ -411,14 +422,13 @@ class survey_question_wiz(osv.osv_memory):
# survey complete
else:
- self._survey_complete(survey_id, partner_id, sur_rec)
- self._view_survey_complete(result):
+ self._survey_complete(cr, uid, survey_id, check_token['partner_id'], sur_name_read, survey_browse, context)
+ self._view_survey_complete(result, context)
-
# don't have acces to this survey
else:
xml_form = etree.Element('form', {'string': _('No access to this survey')})
- etree.SubElement(xml_form, 'separator', {'string': sur_rec.title, 'colspan': "4"})
+ etree.SubElement(xml_form, 'separator', {'string': survey_browse.title, 'colspan': "4"})
etree.SubElement(xml_form, 'label', {'string': "You don't have access to this survey."})
etree.SubElement(xml_form, 'newline')
etree.SubElement(xml_form, 'label', {'string': "The access you have not been given or the deadline has passed."})
@@ -437,26 +447,13 @@ class survey_question_wiz(osv.osv_memory):
return (False, Exception('Report name and Resources ids are required !!!'))
try:
uid = 1
- service = netsvc.LocalService(report_name);
+ service = netsvc.LocalService(report_name)
(result, format) = service.create(cr, uid, res_ids, {}, context)
ret_file_name = addons.get_module_resource('survey', 'report') + file_name + '.pdf'
- with open(ret_file_name, 'wb+') as fp:
+ with open(ret_file_name, 'wb + ') as fp:
fp.write(result)
-
- # hr.applicant: if survey answered directly in system: attach report to applicant
- if context.get('active_model') == 'hr.applicant':
- self.pool.get('hr.applicant').write(cr,uid,[context.get('active_ids')[0]],{'response':context.get('response_id')})
- result = base64.b64encode(result)
- file_name = file_name + '.pdf'
- ir_attachment = self.pool.get('ir.attachment').create(cr, uid,
- {'name': file_name,
- 'datas': result,
- 'datas_fname': file_name,
- 'res_model': context.get('active_model'),
- 'res_id': context.get('active_ids')[0]},
- context=context)
- except Exception,e:
+ except Exception, e:
return (False, str(e))
return (True, ret_file_name)
@@ -469,13 +466,12 @@ class survey_question_wiz(osv.osv_memory):
context = {}
for field in fields_list:
if field.split('_')[0] == 'progress':
- tot_page_id = self.pool.get('survey').browse(cr, uid, context.get('survey_id',False))
+ tot_page_id = self.pool.get('survey').browse(cr, uid, context.get('survey_id', False))
tot_per = (float(100) * (int(field.split('_')[2]) + 1) / len(tot_page_id.page_ids))
value[field] = tot_per
response_obj = self.pool.get('survey.response')
surv_name_wiz = self.pool.get('survey.name.wiz')
- if context.has_key('response_id') and context.get('response_id') and int(context['response_id'][0]) > 0:
- data = super(survey_question_wiz, self).default_get(cr, uid, fields_list, context)
+ if context.get('response_id') and int(context['response_id'][0]) > 0:
response_ans = response_obj.browse(cr, uid, context['response_id'][context['response_no']])
fields_list.sort()
@@ -489,7 +485,7 @@ class survey_question_wiz(osv.osv_memory):
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):
+ 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"):
@@ -500,7 +496,7 @@ class survey_question_wiz(osv.osv_memory):
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):
+ 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":
@@ -508,7 +504,7 @@ class survey_question_wiz(osv.osv_memory):
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 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:
@@ -516,19 +512,17 @@ class survey_question_wiz(osv.osv_memory):
else:
for ans in que.response_answer_ids:
- if str(field.split('_')[1]) == str( ans.answer_id.id):
+ if str(field.split('_')[1]) == str(ans.answer_id.id):
value[field] = ans.answer
else:
-
- if not context.has_key('sur_name_id'):
+ if not context.get('sur_name_id'):
return value
- if context.has_key('active') and context.get('active',False):
+ if context.get('active', False):
return value
- sur_name_read = surv_name_wiz.read(cr, uid, context.get('sur_name_id',False))
- ans_list = []
+ sur_name_read = surv_name_wiz.read(cr, uid, context.get('sur_name_id', False))
- for key,val in safe_eval(sur_name_read.get('store_ans',"{}")).items():
+ for key, val in safe_eval(sur_name_read.get('store_ans', "{}")).items():
for field in fields_list:
if field in list(val):
value[field] = val[field]
@@ -538,16 +532,20 @@ class survey_question_wiz(osv.osv_memory):
"""
Create the Answer of survey and store in survey.response object, and if set validation of question then check the value of question if value is wrong then raise the exception.
"""
- if context is None: context = {}
+ context = context or {}
- survey_question_wiz_id = super(survey_question_wiz,self).create(cr, uid, {'name': vals.get('name')}, context=context)
- if context.get('active',False):
+ check_token = self._check_token(cr, uid, context['survey_id'], context)
+ if not check_token['partner_id'] and not check_token['response_id']:
+ return False
+
+ survey_question_wiz_id = super(survey_question_wiz, self).create(cr, uid, {'name': vals.get('name')}, context=context)
+ if context.get('active', False):
return survey_question_wiz_id
- for key,val in vals.items():
+ for key, val in vals.items():
if key.split('_')[0] == "progress":
vals.pop(key)
- if not context.has_key('sur_name_id') and key.split('_')[0] == "wizardid":
+ if not context.get('sur_name_id') and key.split('_')[0] == "wizardid":
context.update({'sur_name_id': int(key.split('_')[1])})
vals.pop(key)
@@ -560,36 +558,31 @@ class survey_question_wiz(osv.osv_memory):
resp_obj = self.pool.get('survey.response.line')
res_ans_obj = self.pool.get('survey.response.answer')
que_obj = self.pool.get('survey.question')
- sur_name_read = surv_name_wiz.read(cr, uid, context.get('sur_name_id',False), [])
- partner_id = self.pool.get('res.users').browse(cr, uid, uid, context).partner_id.id
- response_id = 0
+ sur_name_read = surv_name_wiz.read(cr, uid, context.get('sur_name_id', False), [])
+ response_id = 0
if not sur_name_read['response']:
- response_id = surv_all_resp_obj.create(cr, uid, {'response_type':'link', 'partner_id':partner_id, 'date_create':datetime.now(), 'survey_id' : context['survey_id']})
- surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], {'response' : tools.ustr(response_id)})
+ response_id = surv_all_resp_obj.create(cr, uid, {'response_type': 'link', 'partner_id': check_token['partner_id'], 'date_create': datetime.now(), 'survey_id': context['survey_id']})
+ surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], {'response': tools.ustr(response_id)})
else:
response_id = int(sur_name_read['response'])
if response_id not in surv_all_resp_obj.search(cr, uid, []):
- response_id = surv_all_resp_obj.create(cr, uid, {'response_type':'link', 'partner_id':partner_id, 'date_create':datetime.now(), 'survey_id' : context.get('survey_id',False)})
- surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)], {'response' : tools.ustr(response_id)})
+ response_id = surv_all_resp_obj.create(cr, uid, {'response_type': 'link', 'partner_id': check_token['partner_id'], 'date_create': datetime.now(), 'survey_id': context.get('survey_id', False)})
+ surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], {'response': tools.ustr(response_id)})
#click first time on next button then increemnet on total start suvey
if not safe_eval(sur_name_read['store_ans']):
- his_id = self.pool.get('survey.history').create(cr, uid, {'partner_id': partner_id, \
- 'date': strftime('%Y-%m-%d %H:%M:%S'), 'survey_id': sur_name_read['survey_id'][0]})
survey_id = sur_name_read['survey_id'][0]
- sur_rec = survey_obj.read(cr, uid, survey_id)
- survey_obj.write(cr, uid, survey_id, {'tot_start_survey' : sur_rec['tot_start_survey'] + 1})
- if context.has_key('cur_id'):
- if context.get('request',False):
- self.pool.get(context.get('object',False)).write(cr, uid, [int(context.get('cur_id',False))], {'response' : response_id})
- self.pool.get(context.get('object',False)).survey_req_done(cr, uid, [int(context.get('cur_id'))], context)
- else:
- self.pool.get(context.get('object',False)).write(cr, uid, [int(context.get('cur_id',False))], {'response' : response_id})
+ survey_browse = survey_obj.read(cr, uid, survey_id)
+ survey_obj.write(cr, uid, survey_id, {'tot_start_survey': survey_browse['tot_start_survey'] + 1})
+ if context.get('cur_id'):
+ self.pool.get(context.get('object', False)).write(cr, uid, [int(context.get('cur_id', False))], {'response': response_id})
+ if context.get('request', False):
+ self.pool.get(context.get('object', False)).survey_req_done(cr, uid, [int(context.get('cur_id'))], context)
if sur_name_read['store_ans'] and type(safe_eval(sur_name_read['store_ans'])) == dict:
sur_name_read['store_ans'] = safe_eval(sur_name_read['store_ans'])
- for key,val in sur_name_read['store_ans'].items():
+ for key, val in sur_name_read['store_ans'].items():
for field in vals:
if field.split('_')[0] == val['question_id']:
click_state = False
@@ -605,7 +598,7 @@ class survey_question_wiz(osv.osv_memory):
if que_id not in que_li:
que_li.append(que_id)
que_rec = que_obj.read(cr, uid, [int(que_id)], [])[0]
- res_data = {
+ res_data = {
'question_id': que_id,
'date_create': datetime.now(),
'state': 'done',
@@ -613,8 +606,8 @@ class survey_question_wiz(osv.osv_memory):
}
resp_id = resp_obj.create(cr, uid, res_data)
resp_id_list.append(resp_id)
- sur_name_read['store_ans'].update({resp_id:{'question_id':que_id}})
- surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)], {'store_ans':sur_name_read['store_ans']})
+ sur_name_read['store_ans'].update({resp_id: {'question_id': que_id}})
+ surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], {'store_ans': sur_name_read['store_ans']})
select_count = 0
numeric_sum = 0
selected_value = []
@@ -625,25 +618,25 @@ class survey_question_wiz(osv.osv_memory):
for key1, val1 in vals.items():
if val1 and key1.split('_')[1] == "table" and key1.split('_')[0] == que_id:
- surv_tbl_column_obj.create(cr, uid, {'response_table_id' : resp_id,'column_id':key1.split('_')[2], 'name':key1.split('_')[3], 'value' : val1})
- sur_name_read['store_ans'][resp_id].update({key1:val1})
+ surv_tbl_column_obj.create(cr, uid, {'response_table_id': resp_id, 'column_id': key1.split('_')[2], 'name': key1.split('_')[3], 'value': val1})
+ sur_name_read['store_ans'][resp_id].update({key1: val1})
select_count += 1
elif val1 and key1.split('_')[1] == "otherfield" and key1.split('_')[0] == que_id:
comment_field = True
- sur_name_read['store_ans'][resp_id].update({key1:val1})
+ sur_name_read['store_ans'][resp_id].update({key1: val1})
select_count += 1
- surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)], {'store_ans':sur_name_read['store_ans']})
+ surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], {'store_ans': sur_name_read['store_ans']})
continue
elif val1 and key1.split('_')[1] == "selection" and key1.split('_')[0] == que_id:
if len(key1.split('_')) > 2:
- ans_create_id = res_ans_obj.create(cr, uid, {'response_id':resp_id, 'answer_id':key1.split('_')[-1], 'column_id' : val1})
+ ans_create_id = res_ans_obj.create(cr, uid, {'response_id': resp_id, 'answer_id': key1.split('_')[-1], 'column_id': val1})
selected_value.append(val1)
response_list.append(str(ans_create_id) + "_" + str(key1.split('_')[-1]))
else:
- ans_create_id = res_ans_obj.create(cr, uid, {'response_id':resp_id, 'answer_id':val1})
- sur_name_read['store_ans'][resp_id].update({key1:val1})
+ ans_create_id = res_ans_obj.create(cr, uid, {'response_id': resp_id, 'answer_id': val1})
+ sur_name_read['store_ans'][resp_id].update({key1: val1})
select_count += 1
elif key1.split('_')[1] == "other" and key1.split('_')[0] == que_id:
@@ -652,87 +645,87 @@ class survey_question_wiz(osv.osv_memory):
else:
error = False
if que_rec['is_comment_require'] and que_rec['comment_valid_type'] == 'must_be_specific_length':
- if (not val1 and que_rec['comment_minimum_no']) or len(val1) < que_rec['comment_minimum_no'] or len(val1) > que_rec['comment_maximum_no']:
+ if (not val1 and que_rec['comment_minimum_no']) or len(val1) < que_rec['comment_minimum_no'] or len(val1) > que_rec['comment_maximum_no']:
error = True
- elif que_rec['is_comment_require'] and que_rec['comment_valid_type'] in ['must_be_whole_number', 'must_be_decimal_number', 'must_be_date']:
+ elif que_rec['is_comment_require'] and que_rec['comment_valid_type'] in ['must_be_whole_number', 'must_be_decimal_number', 'must_be_date']:
error = False
try:
if que_rec['comment_valid_type'] == 'must_be_whole_number':
value = int(val1)
- if value < que_rec['comment_minimum_no'] or value > que_rec['comment_maximum_no']:
+ if value < que_rec['comment_minimum_no'] or value > que_rec['comment_maximum_no']:
error = True
elif que_rec['comment_valid_type'] == 'must_be_decimal_number':
value = float(val1)
- if value < que_rec['comment_minimum_float'] or value > que_rec['comment_maximum_float']:
+ if value < que_rec['comment_minimum_float'] or value > que_rec['comment_maximum_float']:
error = True
elif que_rec['comment_valid_type'] == 'must_be_date':
value = datetime.datetime.strptime(val1, "%Y-%m-%d")
- if value < datetime.datetime.strptime(que_rec['comment_minimum_date'], "%Y-%m-%d") or value > datetime.datetime.strptime(que_rec['comment_maximum_date'], "%Y-%m-%d"):
+ if value < datetime.datetime.strptime(que_rec['comment_minimum_date'], "%Y-%m-%d") or value > datetime.datetime.strptime(que_rec['comment_maximum_date'], "%Y-%m-%d"):
error = True
except:
error = True
- elif que_rec['is_comment_require'] and que_rec['comment_valid_type'] == 'must_be_email_address':
+ elif que_rec['is_comment_require'] and que_rec['comment_valid_type'] == 'must_be_email_address':
import re
- if re.match("^[a-zA-Z0-9._%-+]+@[a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}$", val1) == None:
+ if re.match("^[a-zA-Z0-9._%- + ] + @[a-zA-Z0-9._%-] + .[a-zA-Z]{2, 6}$", val1) == None:
error = True
if error:
for res in resp_id_list:
sur_name_read['store_ans'].pop(res)
raise osv.except_osv(_('Warning!'), "'" + que_rec['question'] + "' \n" + tools.ustr(que_rec['comment_valid_err_msg']))
- resp_obj.write(cr, uid, resp_id, {'comment':val1})
- sur_name_read['store_ans'][resp_id].update({key1:val1})
+ resp_obj.write(cr, uid, resp_id, {'comment': val1})
+ sur_name_read['store_ans'][resp_id].update({key1: val1})
elif val1 and key1.split('_')[1] == "comment" and key1.split('_')[0] == que_id:
- resp_obj.write(cr, uid, resp_id, {'comment':val1})
- sur_name_read['store_ans'][resp_id].update({key1:val1})
+ resp_obj.write(cr, uid, resp_id, {'comment': val1})
+ sur_name_read['store_ans'][resp_id].update({key1: val1})
select_count += 1
- elif val1 and key1.split('_')[0] == que_id and (key1.split('_')[1] == "single" or (len(key1.split('_')) > 2 and key1.split('_')[2] == 'multi')):
+ elif val1 and key1.split('_')[0] == que_id and (key1.split('_')[1] == "single" or (len(key1.split('_')) > 2 and key1.split('_')[2] == 'multi')):
error = False
if que_rec['is_validation_require'] and que_rec['validation_type'] == 'must_be_specific_length':
- if (not val1 and que_rec['validation_minimum_no']) or len(val1) < que_rec['validation_minimum_no'] or len(val1) > que_rec['validation_maximum_no']:
+ if (not val1 and que_rec['validation_minimum_no']) or len(val1) < que_rec['validation_minimum_no'] or len(val1) > que_rec['validation_maximum_no']:
error = True
elif que_rec['is_validation_require'] and que_rec['validation_type'] in ['must_be_whole_number', 'must_be_decimal_number', 'must_be_date']:
error = False
try:
if que_rec['validation_type'] == 'must_be_whole_number':
value = int(val1)
- if value < que_rec['validation_minimum_no'] or value > que_rec['validation_maximum_no']:
+ if value < que_rec['validation_minimum_no'] or value > que_rec['validation_maximum_no']:
error = True
elif que_rec['validation_type'] == 'must_be_decimal_number':
value = float(val1)
- if value < que_rec['validation_minimum_float'] or value > que_rec['validation_maximum_float']:
+ if value < que_rec['validation_minimum_float'] or value > que_rec['validation_maximum_float']:
error = True
elif que_rec['validation_type'] == 'must_be_date':
value = datetime.datetime.strptime(val1, "%Y-%m-%d")
- if value < datetime.datetime.strptime(que_rec['validation_minimum_date'], "%Y-%m-%d") or value > datetime.datetime.strptime(que_rec['validation_maximum_date'], "%Y-%m-%d"):
+ if value < datetime.datetime.strptime(que_rec['validation_minimum_date'], "%Y-%m-%d") or value > datetime.datetime.strptime(que_rec['validation_maximum_date'], "%Y-%m-%d"):
error = True
except:
error = True
elif que_rec['is_validation_require'] and que_rec['validation_type'] == 'must_be_email_address':
import re
- if re.match("^[a-zA-Z0-9._%-+]+@[a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}$", val1) == None:
+ if re.match("^[a-zA-Z0-9._%- + ] + @[a-zA-Z0-9._%-] + .[a-zA-Z]{2, 6}$", val1) == None:
error = True
if error:
for res in resp_id_list:
sur_name_read['store_ans'].pop(res)
raise osv.except_osv(_('Warning!'), "'" + que_rec['question'] + "' \n" + tools.ustr(que_rec['validation_valid_err_msg']))
- if key1.split('_')[1] == "single" :
- resp_obj.write(cr, uid, resp_id, {'single_text':val1})
+ if key1.split('_')[1] == "single":
+ resp_obj.write(cr, uid, resp_id, {'single_text': val1})
else:
- ans_create_id = res_ans_obj.create(cr, uid, {'response_id':resp_id, 'answer_id':key1.split('_')[1], 'answer' : val1})
+ ans_create_id = res_ans_obj.create(cr, uid, {'response_id': resp_id, 'answer_id': key1.split('_')[1], 'answer': val1})
- sur_name_read['store_ans'][resp_id].update({key1:val1})
+ sur_name_read['store_ans'][resp_id].update({key1: val1})
select_count += 1
elif val1 and que_id == key1.split('_')[0] and len(key1.split('_')) > 2 and key1.split('_')[2] == 'numeric':
- if not val1=="0":
+ if not val1 == "0":
try:
numeric_sum += int(val1)
- ans_create_id = res_ans_obj.create(cr, uid, {'response_id':resp_id, 'answer_id':key1.split('_')[1], 'answer' : val1})
- sur_name_read['store_ans'][resp_id].update({key1:val1})
+ ans_create_id = res_ans_obj.create(cr, uid, {'response_id': resp_id, 'answer_id': key1.split('_')[1], 'answer': val1})
+ sur_name_read['store_ans'][resp_id].update({key1: val1})
select_count += 1
except:
for res in resp_id_list:
@@ -741,32 +734,32 @@ class survey_question_wiz(osv.osv_memory):
elif val1 and que_id == key1.split('_')[0] and len(key1.split('_')) == 3:
if type(val1) == type('') or type(val1) == type(u''):
- ans_create_id = res_ans_obj.create(cr, uid, {'response_id':resp_id, 'answer_id':key1.split('_')[1], 'column_id' : key1.split('_')[2], 'value_choice' : val1})
- sur_name_read['store_ans'][resp_id].update({key1:val1})
+ ans_create_id = res_ans_obj.create(cr, uid, {'response_id': resp_id, 'answer_id': key1.split('_')[1], 'column_id': key1.split('_')[2], 'value_choice': val1})
+ sur_name_read['store_ans'][resp_id].update({key1: val1})
else:
- ans_create_id = res_ans_obj.create(cr, uid, {'response_id':resp_id, 'answer_id':key1.split('_')[1], 'column_id' : key1.split('_')[2]})
- sur_name_read['store_ans'][resp_id].update({key1:True})
+ ans_create_id = res_ans_obj.create(cr, uid, {'response_id': resp_id, 'answer_id': key1.split('_')[1], 'column_id': key1.split('_')[2]})
+ sur_name_read['store_ans'][resp_id].update({key1: True})
matrix_list.append(key1.split('_')[0] + '_' + key1.split('_')[1])
select_count += 1
elif val1 and que_id == key1.split('_')[0] and len(key1.split('_')) == 2:
- ans_create_id = res_ans_obj.create(cr, uid, {'response_id':resp_id, 'answer_id':key1.split('_')[-1], 'answer' : val1})
- sur_name_read['store_ans'][resp_id].update({key1:val1})
+ ans_create_id = res_ans_obj.create(cr, uid, {'response_id': resp_id, 'answer_id': key1.split('_')[-1], 'answer': val1})
+ sur_name_read['store_ans'][resp_id].update({key1: val1})
select_count += 1
- surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)], {'store_ans':sur_name_read['store_ans']})
+ surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], {'store_ans': sur_name_read['store_ans']})
- for key,val in vals.items():
+ for key, val in vals.items():
if val and key.split('_')[1] == "commentcolumn" and key.split('_')[0] == que_id:
for res_id in response_list:
if key.split('_')[2] in res_id.split('_')[1]:
- a = res_ans_obj.write(cr, uid, [res_id.split('_')[0]], {'comment_field':val})
- sur_name_read['store_ans'][resp_id].update({key:val})
+ a = res_ans_obj.write(cr, uid, [res_id.split('_')[0]], {'comment_field': val})
+ sur_name_read['store_ans'][resp_id].update({key: val})
if comment_field and comment_value:
for res in resp_id_list:
sur_name_read['store_ans'].pop(res)
- raise osv.except_osv(_('Warning!'), "'" + que_rec['question'] + "' " + tools.ustr(que_rec['make_comment_field_err_msg']))
+ raise osv.except_osv(_('Warning!'), "'" + que_rec['question'] + "' " + tools.ustr(que_rec['make_comment_field_err_msg']))
if que_rec['type'] == "rating_scale" and que_rec['rating_allow_one_column_require'] and len(selected_value) > len(list(set(selected_value))):
for res in resp_id_list:
@@ -774,14 +767,14 @@ class survey_question_wiz(osv.osv_memory):
raise osv.except_osv(_('Warning!'), "'" + que_rec['question'] + "'\n" + _("You cannot select the same answer more than one time."))
if not select_count:
- resp_obj.write(cr, uid, resp_id, {'state':'skip'})
+ resp_obj.write(cr, uid, resp_id, {'state': 'skip'})
if que_rec['numeric_required_sum'] and numeric_sum > que_rec['numeric_required_sum']:
for res in resp_id_list:
sur_name_read['store_ans'].pop(res)
raise osv.except_osv(_('Warning!'), "'" + que_rec['question'] + "' " + tools.ustr(que_rec['numeric_required_sum_err_msg']))
- if que_rec['type'] in ['multiple_textboxes_diff_type', 'multiple_choice_multiple_ans','matrix_of_choices_only_one_ans','matrix_of_choices_only_multi_ans','rating_scale','multiple_textboxes','numerical_textboxes','date','date_and_time'] and que_rec['is_require_answer']:
+ if que_rec['type'] in ['multiple_textboxes_diff_type', 'multiple_choice_multiple_ans', 'matrix_of_choices_only_one_ans', 'matrix_of_choices_only_multi_ans', 'rating_scale', 'multiple_textboxes', 'numerical_textboxes', 'date', 'date_and_time'] and que_rec['is_require_answer']:
if matrix_list:
if (que_rec['required_type'] == 'all' and len(list(set(matrix_list))) < len(que_rec['answer_choice_ids'])) or \
(que_rec['required_type'] == 'at least' and len(list(set(matrix_list))) < que_rec['req_ans']) or \
@@ -801,7 +794,7 @@ class survey_question_wiz(osv.osv_memory):
sur_name_read['store_ans'].pop(res)
raise osv.except_osv(_('Warning!'), "'" + que_rec['question'] + "' " + tools.ustr(que_rec['req_error_msg']))
- if que_rec['type'] in ['multiple_choice_only_one_ans','single_textbox','comment'] and que_rec['is_require_answer'] and select_count <= 0:
+ if que_rec['type'] in ['multiple_choice_only_one_ans', 'single_textbox', 'comment'] and que_rec['is_require_answer'] and select_count <= 0:
for res in resp_id_list:
sur_name_read['store_ans'].pop(res)
raise osv.except_osv(_('Warning!'), "'" + que_rec['question'] + "' " + tools.ustr(que_rec['req_error_msg']))
@@ -809,12 +802,12 @@ class survey_question_wiz(osv.osv_memory):
else:
resp_id_list = []
for update in click_update:
- que_rec = que_obj.read(cr, uid , [int(sur_name_read['store_ans'][update]['question_id'])], [])[0]
- res_ans_obj.unlink(cr, uid,res_ans_obj.search(cr, uid, [('response_id', '=', update)]))
- surv_tbl_column_obj.unlink(cr, uid,surv_tbl_column_obj.search(cr, uid, [('response_table_id', '=', update)]))
+ que_rec = que_obj.read(cr, uid, [int(sur_name_read['store_ans'][update]['question_id'])], [])[0]
+ res_ans_obj.unlink(cr, uid, res_ans_obj.search(cr, uid, [('response_id', '=', update)]))
+ surv_tbl_column_obj.unlink(cr, uid, surv_tbl_column_obj.search(cr, uid, [('response_table_id', '=', update)]))
resp_id_list.append(update)
- sur_name_read['store_ans'].update({update:{'question_id':sur_name_read['store_ans'][update]['question_id']}})
- surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)], {'store_ans':sur_name_read['store_ans']})
+ sur_name_read['store_ans'].update({update: {'question_id': sur_name_read['store_ans'][update]['question_id']}})
+ surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], {'store_ans': sur_name_read['store_ans']})
select_count = 0
numeric_sum = 0
selected_value = []
@@ -827,26 +820,26 @@ class survey_question_wiz(osv.osv_memory):
ans_id_len = key.split('_')
if ans_id_len[0] == sur_name_read['store_ans'][update]['question_id']:
if val and key.split('_')[1] == "table":
- surv_tbl_column_obj.create(cr, uid, {'response_table_id' : update,'column_id':key.split('_')[2], 'name':key.split('_')[3], 'value' : val})
- sur_name_read['store_ans'][update].update({key:val})
+ surv_tbl_column_obj.create(cr, uid, {'response_table_id': update, 'column_id': key.split('_')[2], 'name': key.split('_')[3], 'value': val})
+ sur_name_read['store_ans'][update].update({key: val})
resp_obj.write(cr, uid, update, {'state': 'done'})
- elif val and key.split('_')[1] == "otherfield" :
+ elif val and key.split('_')[1] == "otherfield":
comment_field = True
- sur_name_read['store_ans'][update].update({key:val})
+ sur_name_read['store_ans'][update].update({key: val})
select_count += 1
- surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)], {'store_ans':sur_name_read['store_ans']})
+ surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], {'store_ans': sur_name_read['store_ans']})
continue
elif val and key.split('_')[1] == "selection":
if len(key.split('_')) > 2:
- ans_create_id = res_ans_obj.create(cr, uid, {'response_id':update, 'answer_id':key.split('_')[-1], 'column_id' : val})
+ ans_create_id = res_ans_obj.create(cr, uid, {'response_id': update, 'answer_id': key.split('_')[-1], 'column_id': val})
selected_value.append(val)
response_list.append(str(ans_create_id) + "_" + str(key.split('_')[-1]))
else:
- ans_create_id = res_ans_obj.create(cr, uid, {'response_id':update, 'answer_id': val})
+ ans_create_id = res_ans_obj.create(cr, uid, {'response_id': update, 'answer_id': val})
resp_obj.write(cr, uid, update, {'state': 'done'})
- sur_name_read['store_ans'][update].update({key:val})
+ sur_name_read['store_ans'][update].update({key: val})
select_count += 1
elif key.split('_')[1] == "other":
@@ -854,82 +847,82 @@ class survey_question_wiz(osv.osv_memory):
comment_value = True
else:
error = False
- if que_rec['is_comment_require'] and que_rec['comment_valid_type'] == 'must_be_specific_length':
- if (not val and que_rec['comment_minimum_no']) or len(val) < que_rec['comment_minimum_no'] or len(val) > que_rec['comment_maximum_no']:
+ if que_rec['is_comment_require'] and que_rec['comment_valid_type'] == 'must_be_specific_length':
+ if (not val and que_rec['comment_minimum_no']) or len(val) < que_rec['comment_minimum_no'] or len(val) > que_rec['comment_maximum_no']:
error = True
- elif que_rec['is_comment_require'] and que_rec['comment_valid_type'] in ['must_be_whole_number', 'must_be_decimal_number', 'must_be_date']:
+ elif que_rec['is_comment_require'] and que_rec['comment_valid_type'] in ['must_be_whole_number', 'must_be_decimal_number', 'must_be_date']:
try:
if que_rec['comment_valid_type'] == 'must_be_whole_number':
value = int(val)
- if value < que_rec['comment_minimum_no'] or value > que_rec['comment_maximum_no']:
+ if value < que_rec['comment_minimum_no'] or value > que_rec['comment_maximum_no']:
error = True
elif que_rec['comment_valid_type'] == 'must_be_decimal_number':
value = float(val)
- if value < que_rec['comment_minimum_float'] or value > que_rec['comment_maximum_float']:
+ if value < que_rec['comment_minimum_float'] or value > que_rec['comment_maximum_float']:
error = True
elif que_rec['comment_valid_type'] == 'must_be_date':
value = datetime.datetime.strptime(val, "%Y-%m-%d")
- if value < datetime.datetime.strptime(que_rec['comment_minimum_date'], "%Y-%m-%d") or value > datetime.datetime.strptime(que_rec['comment_maximum_date'], "%Y-%m-%d"):
+ if value < datetime.datetime.strptime(que_rec['comment_minimum_date'], "%Y-%m-%d") or value > datetime.datetime.strptime(que_rec['comment_maximum_date'], "%Y-%m-%d"):
error = True
except:
error = True
- elif que_rec['is_comment_require'] and que_rec['comment_valid_type'] == 'must_be_email_address':
+ elif que_rec['is_comment_require'] and que_rec['comment_valid_type'] == 'must_be_email_address':
import re
- if re.match("^[a-zA-Z0-9._%-+]+@[a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}$", val) == None:
+ if re.match("^[a-zA-Z0-9._%- + ] + @[a-zA-Z0-9._%-] + .[a-zA-Z]{2, 6}$", val) == None:
error = True
if error:
raise osv.except_osv(_('Warning!'), "'" + que_rec['question'] + "' \n" + tools.ustr(que_rec['comment_valid_err_msg']))
- resp_obj.write(cr, uid, update, {'comment':val,'state': 'done'})
- sur_name_read['store_ans'][update].update({key:val})
+ resp_obj.write(cr, uid, update, {'comment': val, 'state': 'done'})
+ sur_name_read['store_ans'][update].update({key: val})
elif val and key.split('_')[1] == "comment":
- resp_obj.write(cr, uid, update, {'comment':val,'state': 'done'})
- sur_name_read['store_ans'][update].update({key:val})
+ resp_obj.write(cr, uid, update, {'comment': val, 'state': 'done'})
+ sur_name_read['store_ans'][update].update({key: val})
select_count += 1
- elif val and (key.split('_')[1] == "single" or (len(key.split('_')) > 2 and key.split('_')[2] == 'multi')):
+ elif val and (key.split('_')[1] == "single" or (len(key.split('_')) > 2 and key.split('_')[2] == 'multi')):
error = False
if que_rec['is_validation_require'] and que_rec['validation_type'] == 'must_be_specific_length':
- if (not val and que_rec['validation_minimum_no']) or len(val) < que_rec['validation_minimum_no'] or len(val) > que_rec['validation_maximum_no']:
+ if (not val and que_rec['validation_minimum_no']) or len(val) < que_rec['validation_minimum_no'] or len(val) > que_rec['validation_maximum_no']:
error = True
elif que_rec['is_validation_require'] and que_rec['validation_type'] in ['must_be_whole_number', 'must_be_decimal_number', 'must_be_date']:
error = False
try:
if que_rec['validation_type'] == 'must_be_whole_number':
value = int(val)
- if value < que_rec['validation_minimum_no'] or value > que_rec['validation_maximum_no']:
+ if value < que_rec['validation_minimum_no'] or value > que_rec['validation_maximum_no']:
error = True
elif que_rec['validation_type'] == 'must_be_decimal_number':
value = float(val)
- if value < que_rec['validation_minimum_float'] or value > que_rec['validation_maximum_float']:
+ if value < que_rec['validation_minimum_float'] or value > que_rec['validation_maximum_float']:
error = True
elif que_rec['validation_type'] == 'must_be_date':
value = datetime.datetime.strptime(val, "%Y-%m-%d")
- if value < datetime.datetime.strptime(que_rec['validation_minimum_date'], "%Y-%m-%d") or value > datetime.datetime.strptime(que_rec['validation_maximum_date'], "%Y-%m-%d"):
+ if value < datetime.datetime.strptime(que_rec['validation_minimum_date'], "%Y-%m-%d") or value > datetime.datetime.strptime(que_rec['validation_maximum_date'], "%Y-%m-%d"):
error = True
- except Exception ,e:
+ except Exception:
error = True
- elif que_rec['is_validation_require'] and que_rec['validation_type'] == 'must_be_email_address':
+ elif que_rec['is_validation_require'] and que_rec['validation_type'] == 'must_be_email_address':
import re
- if re.match("^[a-zA-Z0-9._%-+]+@[a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}$", val) == None:
+ if re.match("^[a-zA-Z0-9._%- + ] + @[a-zA-Z0-9._%-] + .[a-zA-Z]{2, 6}$", val) == None:
error = True
if error:
raise osv.except_osv(_('Warning!'), "'" + que_rec['question'] + "' \n" + tools.ustr(que_rec['validation_valid_err_msg']))
- if key.split('_')[1] == "single" :
- resp_obj.write(cr, uid, update, {'single_text':val,'state': 'done'})
+ if key.split('_')[1] == "single":
+ resp_obj.write(cr, uid, update, {'single_text': val, 'state': 'done'})
else:
resp_obj.write(cr, uid, update, {'state': 'done'})
- ans_create_id = res_ans_obj.create(cr, uid, {'response_id':update, 'answer_id':ans_id_len[1], 'answer' : val})
- sur_name_read['store_ans'][update].update({key:val})
+ ans_create_id = res_ans_obj.create(cr, uid, {'response_id': update, 'answer_id': ans_id_len[1], 'answer': val})
+ sur_name_read['store_ans'][update].update({key: val})
select_count += 1
elif val and len(key.split('_')) > 2 and key.split('_')[2] == 'numeric':
- if not val=="0":
+ if not val == "0":
try:
numeric_sum += int(val)
resp_obj.write(cr, uid, update, {'state': 'done'})
- ans_create_id = res_ans_obj.create(cr, uid, {'response_id': update, 'answer_id':ans_id_len[1], 'answer' : val})
- sur_name_read['store_ans'][update].update({key:val})
+ ans_create_id = res_ans_obj.create(cr, uid, {'response_id': update, 'answer_id': ans_id_len[1], 'answer': val})
+ sur_name_read['store_ans'][update].update({key: val})
select_count += 1
except:
raise osv.except_osv(_('Warning!'), "'" + que_rec['question'] + "'\n" + _("Please enter an integer value."))
@@ -937,30 +930,30 @@ class survey_question_wiz(osv.osv_memory):
elif val and len(key.split('_')) == 3:
resp_obj.write(cr, uid, update, {'state': 'done'})
if type(val) == type('') or type(val) == type(u''):
- ans_create_id = res_ans_obj.create(cr, uid, {'response_id': update, 'answer_id':ans_id_len[1], 'column_id' : ans_id_len[2], 'value_choice' : val})
- sur_name_read['store_ans'][update].update({key:val})
+ ans_create_id = res_ans_obj.create(cr, uid, {'response_id': update, 'answer_id': ans_id_len[1], 'column_id': ans_id_len[2], 'value_choice': val})
+ sur_name_read['store_ans'][update].update({key: val})
else:
- ans_create_id = res_ans_obj.create(cr, uid, {'response_id': update, 'answer_id':ans_id_len[1], 'column_id' : ans_id_len[2]})
- sur_name_read['store_ans'][update].update({key:True})
+ ans_create_id = res_ans_obj.create(cr, uid, {'response_id': update, 'answer_id': ans_id_len[1], 'column_id': ans_id_len[2]})
+ sur_name_read['store_ans'][update].update({key: True})
matrix_list.append(key.split('_')[0] + '_' + key.split('_')[1])
select_count += 1
elif val and len(key.split('_')) == 2:
resp_obj.write(cr, uid, update, {'state': 'done'})
- ans_create_id = res_ans_obj.create(cr, uid, {'response_id': update, 'answer_id':ans_id_len[-1], 'answer' : val})
- sur_name_read['store_ans'][update].update({key:val})
+ ans_create_id = res_ans_obj.create(cr, uid, {'response_id': update, 'answer_id': ans_id_len[-1], 'answer': val})
+ sur_name_read['store_ans'][update].update({key: val})
select_count += 1
- surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)], {'store_ans': sur_name_read['store_ans']})
+ surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], {'store_ans': sur_name_read['store_ans']})
- for key,val in vals.items():
+ for key, val in vals.items():
if val and key.split('_')[1] == "commentcolumn" and key.split('_')[0] == sur_name_read['store_ans'][update]['question_id']:
for res_id in response_list:
if key.split('_')[2] in res_id.split('_')[1]:
- a = res_ans_obj.write(cr, uid, [res_id.split('_')[0]], {'comment_field':val})
- sur_name_read['store_ans'][update].update({key:val})
+ res_ans_obj.write(cr, uid, [res_id.split('_')[0]], {'comment_field': val})
+ sur_name_read['store_ans'][update].update({key: val})
if comment_field and comment_value:
- raise osv.except_osv(_('Warning!'), "'" + que_rec['question'] + "' " + tools.ustr(que_rec['make_comment_field_err_msg']))
+ raise osv.except_osv(_('Warning!'), "'" + que_rec['question'] + "' " + tools.ustr(que_rec['make_comment_field_err_msg']))
if que_rec['type'] == "rating_scale" and que_rec['rating_allow_one_column_require'] and len(selected_value) > len(list(set(selected_value))):
raise osv.except_osv(_('Warning!'), "'" + que_rec['question'] + "\n" + _("You cannot select same answer more than one time.'"))
@@ -971,7 +964,7 @@ class survey_question_wiz(osv.osv_memory):
if not select_count:
resp_obj.write(cr, uid, update, {'state': 'skip'})
- if que_rec['type'] in ['multiple_textboxes_diff_type','multiple_choice_multiple_ans','matrix_of_choices_only_one_ans','matrix_of_choices_only_multi_ans','rating_scale','multiple_textboxes','numerical_textboxes','date','date_and_time'] and que_rec['is_require_answer']:
+ if que_rec['type'] in ['multiple_textboxes_diff_type', 'multiple_choice_multiple_ans', 'matrix_of_choices_only_one_ans', 'matrix_of_choices_only_multi_ans', 'rating_scale', 'multiple_textboxes', 'numerical_textboxes', 'date', 'date_and_time'] and que_rec['is_require_answer']:
if matrix_list:
if (que_rec['required_type'] == 'all' and len(list(set(matrix_list))) < len(que_rec['answer_choice_ids'])) or \
(que_rec['required_type'] == 'at least' and len(list(set(matrix_list))) < que_rec['req_ans']) or \
@@ -987,7 +980,7 @@ class survey_question_wiz(osv.osv_memory):
(que_rec['required_type'] == 'a range' and (select_count < que_rec['minimum_req_ans'] or select_count > que_rec['maximum_req_ans'])):
raise osv.except_osv(_('Warning!'), "'" + que_rec['question'] + "' " + tools.ustr(que_rec['req_error_msg']))
- if que_rec['type'] in ['multiple_choice_only_one_ans','single_textbox','comment'] and que_rec['is_require_answer'] and select_count <= 0:
+ if que_rec['type'] in ['multiple_choice_only_one_ans', 'single_textbox', 'comment'] and que_rec['is_require_answer'] and select_count <= 0:
raise osv.except_osv(_('Warning!'), "'" + que_rec['question'] + "' " + tools.ustr(que_rec['req_error_msg']))
return survey_question_wiz_id
@@ -998,11 +991,11 @@ class survey_question_wiz(osv.osv_memory):
"""
if context is None:
context = {}
- for key,val in context.items():
+ for key, val in context.items():
if type(key) == type(True):
context.pop(key)
- view_id = self.pool.get('ir.ui.view').search(cr,uid,[('model','=','survey.question'),\
- ('name','=','survey_question_wizard_test')])
+ view_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.question'), \
+ ('name', '=', 'survey_question_wizard_test')])
return {
'view_type': 'form',
"view_mode": 'form',
@@ -1019,11 +1012,11 @@ class survey_question_wiz(osv.osv_memory):
"""
if context is None:
context = {}
- for key,val in context.items():
+ for key, val in context.items():
if type(key) == type(True):
context.pop(key)
- view_id = self.pool.get('ir.ui.view').search(cr,uid,[('model','=','survey.page'),\
- ('name','=','survey_page_wizard_test')])
+ view_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.page'), \
+ ('name', '=', 'survey_page_wizard_test')])
return {
'view_type': 'form',
"view_mode": 'form',
@@ -1040,18 +1033,18 @@ class survey_question_wiz(osv.osv_memory):
"""
if context is None:
context = {}
- for key,val in context.items():
+ for key, val in context.items():
if type(key) == type(True):
context.pop(key)
- view_id = self.pool.get('ir.ui.view').search(cr,uid,[('model','=','survey.page'),\
- ('name','=','survey_page_wizard_test')])
+ view_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.page'), \
+ ('name', '=', 'survey_page_wizard_test')])
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'survey.page',
'type': 'ir.actions.act_window',
'target': 'new',
- 'res_id': int(context.get('page_id',0)),
+ 'res_id': int(context.get('page_id', 0)),
'view_id': view_id,
'context': context
}
@@ -1062,27 +1055,27 @@ class survey_question_wiz(osv.osv_memory):
"""
if context is None:
context = {}
- for key,val in context.items():
+ for key, val in context.items():
if type(key) == type(True):
context.pop(key)
- self.pool.get('survey.page').unlink(cr, uid, [context.get('page_id',False)])
- for survey in self.pool.get('survey').browse(cr, uid, [context.get('survey_id',False)], context=context):
+ self.pool.get('survey.page').unlink(cr, uid, [context.get('page_id', False)])
+ for survey in self.pool.get('survey').browse(cr, uid, [context.get('survey_id', False)], context=context):
if not survey.page_ids:
- return {'type':'ir.actions.act_window_close'}
+ return {'type': 'ir.actions.act_window_close'}
- search_id = self.pool.get('ir.ui.view').search(cr,uid,[('model','=','survey.question.wiz'),\
- ('name','=','Survey Search')])
+ search_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.question.wiz'), \
+ ('name', '=', 'Survey Search')])
surv_name_wiz = self.pool.get('survey.name.wiz')
- surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)], \
- {'transfer':True, 'page_no' : context.get('page_number',False) })
+ surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], \
+ {'transfer': True, 'page_no': context.get('page_number', False)})
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],
+ 'search_view_id': search_id[0],
'context': context
}
@@ -1092,18 +1085,18 @@ class survey_question_wiz(osv.osv_memory):
"""
if context is None:
context = {}
- for key,val in context.items():
+ for key, val in context.items():
if type(key) == type(True):
context.pop(key)
- view_id = self.pool.get('ir.ui.view').search(cr,uid,[('model','=','survey.question'),\
- ('name','=','survey_question_wizard_test')])
+ view_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.question'), \
+ ('name', '=', 'survey_question_wizard_test')])
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'survey.question',
'type': 'ir.actions.act_window',
'target': 'new',
- 'res_id' : int(context.get('question_id',0)),
+ 'res_id': int(context.get('question_id', 0)),
'view_id': view_id,
'context': context
}
@@ -1114,17 +1107,17 @@ class survey_question_wiz(osv.osv_memory):
"""
if context is None:
context = {}
- for key,val in context.items():
+ for key, val in context.items():
if type(key) == type(True):
context.pop(key)
que_obj = self.pool.get('survey.question')
- que_obj.unlink(cr, uid, [context.get('question_id',False)])
- search_id = self.pool.get('ir.ui.view').search(cr,uid,[('model','=','survey.question.wiz'),\
- ('name','=','Survey Search')])
+ que_obj.unlink(cr, uid, [context.get('question_id', False)])
+ search_id = self.pool.get('ir.ui.view').search(cr, uid, [('model', '=', 'survey.question.wiz'), \
+ ('name', '=', 'Survey Search')])
surv_name_wiz = self.pool.get('survey.name.wiz')
- surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)],\
- {'transfer':True, 'page_no' : context.get('page_number',0) })
+ surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], \
+ {'transfer': True, 'page_no': context.get('page_number', 0)})
return {
'view_type': 'form',
"view_mode": 'form',
@@ -1143,12 +1136,12 @@ class survey_question_wiz(osv.osv_memory):
context = {}
search_obj = self.pool.get('ir.ui.view')
surv_name_wiz = self.pool.get('survey.name.wiz')
- search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),\
- ('name','=','Survey Search')])
- wiz_id = surv_name_wiz.create(cr,uid, {'survey_id': context.get('survey_id',False),'page_no' :-1,'page':'next','transfer' :1,'response':0})
- context.update({'sur_name_id' :wiz_id, 'response_no': context.get('response_no',0) - 1})
+ search_id = search_obj.search(cr, uid, [('model', '=', 'survey.question.wiz'), \
+ ('name', '=', 'Survey Search')])
+ wiz_id = surv_name_wiz.create(cr, uid, {'survey_id': context.get('survey_id', False), 'page_no': -1, 'page': 'next', 'transfer': 1, 'response': 0})
+ context.update({'sur_name_id': wiz_id, 'response_no': context.get('response_no', 0) - 1})
- if context.get('response_no',0) + 1 > len(context.get('response_id',0)):
+ if context.get('response_no', 0) + 1 > len(context.get('response_id', 0)):
return {}
return {
'view_type': 'form',
@@ -1168,12 +1161,12 @@ class survey_question_wiz(osv.osv_memory):
context = {}
search_obj = self.pool.get('ir.ui.view')
surv_name_wiz = self.pool.get('survey.name.wiz')
- search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),\
- ('name','=','Survey Search')])
- wiz_id = surv_name_wiz.create(cr,uid, {'survey_id' : context.get('survey_id',False),'page_no' :-1,'page':'next','transfer' :1,'response':0})
- context.update({'sur_name_id' :wiz_id, 'response_no' : context.get('response_no',0) + 1})
+ search_id = search_obj.search(cr, uid, [('model', '=', 'survey.question.wiz'), \
+ ('name', '=', 'Survey Search')])
+ wiz_id = surv_name_wiz.create(cr, uid, {'survey_id': context.get('survey_id', False), 'page_no': -1, 'page': 'next', 'transfer': 1, 'response': 0})
+ context.update({'sur_name_id': wiz_id, 'response_no': context.get('response_no', 0) + 1})
- if context.get('response_no',0) + 1 > len(context.get('response_id',0)):
+ if context.get('response_no', 0) + 1 > len(context.get('response_id', 0)):
return {}
return {
'view_type': 'form',
@@ -1193,8 +1186,8 @@ class survey_question_wiz(osv.osv_memory):
context = {}
surv_name_wiz = self.pool.get('survey.name.wiz')
search_obj = self.pool.get('ir.ui.view')
- search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),('name','=','Survey Search')])
- surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)], {'transfer':True, 'page':'next'})
+ search_id = search_obj.search(cr, uid, [('model', '=', 'survey.question.wiz'), ('name', '=', 'Survey Search')])
+ surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], {'transfer': True, 'page': 'next'})
return {
'view_type': 'form',
"view_mode": 'form',
@@ -1213,9 +1206,9 @@ class survey_question_wiz(osv.osv_memory):
context = {}
surv_name_wiz = self.pool.get('survey.name.wiz')
search_obj = self.pool.get('ir.ui.view')
- search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),\
- ('name','=','Survey Search')])
- surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)], {'transfer':True, 'page':'previous'})
+ search_id = search_obj.search(cr, uid, [('model', '=', 'survey.question.wiz'), \
+ ('name', '=', 'Survey Search')])
+ surv_name_wiz.write(cr, uid, [context.get('sur_name_id', False)], {'transfer': True, 'page': 'previous'})
return {
'view_type': 'form',
"view_mode": 'form',
@@ -1228,4 +1221,4 @@ class survey_question_wiz(osv.osv_memory):
survey_question_wiz()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+# vim: expandtab: smartindent: tabstop=4: softtabstop=4: shiftwidth=4:
diff --git a/addons/survey/wizard/survey_selection.py b/addons/survey/wizard/survey_selection.py
index 496f871394c..3eadb3802a9 100644
--- a/addons/survey/wizard/survey_selection.py
+++ b/addons/survey/wizard/survey_selection.py
@@ -66,23 +66,17 @@ class survey_name_wiz(osv.osv_memory):
"""
survey_obj = self.pool.get('survey')
search_obj = self.pool.get('ir.ui.view')
- if context is None: context = {}
+ context = context or {}
this = self.browse(cr, uid, ids, context=context)[0]
survey_id = this.survey_id.id
context.update({'survey_id': survey_id, 'sur_name_id': this.id})
- cr.execute('select count(id) from survey_history where user_id=%s\
- and survey_id=%s' % (uid,survey_id))
-
- res = cr.fetchone()[0]
- sur_rec = survey_obj.browse(cr,uid,survey_id,context=context)
- if sur_rec.response_user and res >= sur_rec.response_user:
- raise osv.except_osv(_('Warning!'),_("You cannot give response for this survey more than %s times.") % (sur_rec.response_user))
+ sur_rec = survey_obj.browse(cr, uid, survey_id, context=context)
if sur_rec.max_response_limit and sur_rec.max_response_limit <= sur_rec.tot_start_survey:
- raise osv.except_osv(_('Warning!'),_("You cannot give more responses. Please contact the author of this survey for further assistance."))
+ raise osv.except_osv(_('Warning!'), _("You cannot give more responses. Please contact the author of this survey for further assistance."))
- search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),('name','=','Survey Search')])
+ search_id = search_obj.search(cr, uid, [('model', '=', 'survey.question.wiz'), ('name', '=', 'Survey Search')])
return {
'view_type': 'form',
"view_mode": 'form',
diff --git a/addons/survey/wizard/survey_selection.xml b/addons/survey/wizard/survey_selection.xml
index de1231b53fb..41feba775c6 100644
--- a/addons/survey/wizard/survey_selection.xml
+++ b/addons/survey/wizard/survey_selection.xml
@@ -5,7 +5,7 @@
Display Survey List
-->
-
+