diff --git a/addons/survey/__terp__.py b/addons/survey/__terp__.py
index 1074d429f62..a06216b362d 100644
--- a/addons/survey/__terp__.py
+++ b/addons/survey/__terp__.py
@@ -41,7 +41,8 @@
'security/ir.model.access.csv',
'wizard/survey_print_statistics.xml',
'wizard/survey_print_answer.xml',
- 'wizard/survey_browse_answer.xml'],
+ 'wizard/survey_browse_answer.xml',
+ 'wizard/survey_print.xml'],
'demo_xml': ['survey_demo.xml'],
'installable': True,
'active': False,
diff --git a/addons/survey/survey_view.xml b/addons/survey/survey_view.xml
index 0f0a482604f..2032ed8ffe4 100644
--- a/addons/survey/survey_view.xml
+++ b/addons/survey/survey_view.xml
@@ -243,8 +243,6 @@
string="Answer Survey" type="action" icon="gtk-execute" context="{'survey_id': active_id}" attrs="{'invisible':[('state','!=','open')]}"/>
-
diff --git a/addons/survey/survey_wizard.xml b/addons/survey/survey_wizard.xml
index 2bc7b7d1910..1654a426b46 100644
--- a/addons/survey/survey_wizard.xml
+++ b/addons/survey/survey_wizard.xml
@@ -5,8 +5,5 @@
-
-
diff --git a/addons/survey/wizard/__init__.py b/addons/survey/wizard/__init__.py
index 9ff781484e2..5221f26db0e 100755
--- a/addons/survey/wizard/__init__.py
+++ b/addons/survey/wizard/__init__.py
@@ -21,11 +21,11 @@
##############################################################################
import wizard_survey
-import wizard_print_survey
import survey_print_statistics
import survey_print_answer
import survey_browse_answer
import survey_selection
import survey_answer
+import survey_print
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py
index 66da955430c..b8a1ce93266 100644
--- a/addons/survey/wizard/survey_answer.py
+++ b/addons/survey/wizard/survey_answer.py
@@ -36,6 +36,17 @@ class survey_question_wiz(osv.osv_memory):
'name': fields.integer('Number'),
}
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.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param view_id : view id of the current object.
+ @param view_type : which type of view is create. like :- form, tree ,search etc...
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for created view of particular survey pages.
+ """
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')
@@ -401,6 +412,18 @@ class survey_question_wiz(osv.osv_memory):
return result
def create_report(self, cr, uid, res_ids, report_name=False, file_name=False, context=None):
+ """
+ If any user give answer of survey then last create report of this answer and if 'E-mail Notification on Response' set True in survey then send mail on responsible person of this survey and attach survey answer report in pdf format.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param res_ids: List of survey answer IDs,
+ @param report_name: name of the report,
+ @param file_name: To give file name of the report,
+ @param context: A standard dictionary for contextual values,
+ @return : Dictionary value for created report with file name.
+ """
if not report_name or not res_ids:
return (False, Exception('Report name and Resources ids are required !!!'))
try:
@@ -418,6 +441,16 @@ class survey_question_wiz(osv.osv_memory):
return (True, ret_file_name)
def default_get(self, cr, uid, fields_list, context=None):
+ """
+ Assign Default value in particular field. If Browse Answers wizard run then read the value into database and Assigne to a particular fields.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param fields_list: List of fields of current view,
+ @param context: A standard dictionary for contextual values,
+ @return : Dictionary value for fields list with value.
+ """
value = {}
for field in fields_list:
if field.split('_')[0] == 'progress':
@@ -488,6 +521,16 @@ class survey_question_wiz(osv.osv_memory):
return value
def create(self, cr, uid, vals, context=None):
+ """
+ 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.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param vals: Values,
+ @param context: A standard dictionary for contextual values
+ @return : True.
+ """
if context.has_key('active') and context.get('active',False):
return True
@@ -719,7 +762,7 @@ class survey_question_wiz(osv.osv_memory):
if not select_count:
resp_obj.write(cr, uid, resp_id, {'state':'skip'})
- if que_rec['numeric_required_sum'] and numeric_sum > que_rec['numeric_required_sum']:
+ if que_rec[also'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(_('Error re !'), _("'" + que_rec['question'] + "' " + tools.ustr(que_rec['numeric_required_sum_err_msg'])))
@@ -936,6 +979,16 @@ class survey_question_wiz(osv.osv_memory):
return True
def action_new_question(self,cr, uid, ids, context):
+ """
+ New survey.Question form.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of survey.question.wiz IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for Open new survey.Qestion form.
+ """
for key,val in context.items():
if type(key) == type(True):
context.pop(key)
@@ -951,6 +1004,16 @@ class survey_question_wiz(osv.osv_memory):
}
def action_new_page(self, cr, uid, ids, context):
+ """
+ New survey.Page form.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of survey.question.wiz IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for Open new survey.page form.
+ """
for key,val in context.items():
if type(key) == type(True):
context.pop(key)
@@ -966,6 +1029,16 @@ class survey_question_wiz(osv.osv_memory):
}
def action_edit_page(self,cr, uid, ids, context):
+ """
+ Edit survey.page.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of survey.question.wiz IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for Open Edit survey.page form.
+ """
for key,val in context.items():
if type(key) == type(True):
context.pop(key)
@@ -982,6 +1055,16 @@ class survey_question_wiz(osv.osv_memory):
}
def action_delete_page(self,cr, uid, ids, context):
+ """
+ Delete survey.page.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of survey.question.wiz IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for Open next survey.page form, but delete the selected page.
+ """
for key,val in context.items():
if type(key) == type(True):
context.pop(key)
@@ -1001,6 +1084,16 @@ class survey_question_wiz(osv.osv_memory):
}
def action_edit_question(self,cr, uid, ids, context):
+ """
+ Edit survey.question.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of survey.question.wiz IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for Open Edit survey.question form.
+ """
for key,val in context.items():
if type(key) == type(True):
context.pop(key)
@@ -1017,6 +1110,16 @@ class survey_question_wiz(osv.osv_memory):
}
def action_delete_question(self,cr, uid, ids, context):
+ """
+ Edit survey.question.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of survey.question.wiz IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for Open same survey.page form, but delete the selected survey.question in current survey.page.
+ """
for key,val in context.items():
if type(key) == type(True):
context.pop(key)
@@ -1037,6 +1140,16 @@ class survey_question_wiz(osv.osv_memory):
}
def action_forward_previous(self, cr, uid, ids, context=None):
+ """
+ Goes to previous Survey Answer.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of survey.question.wiz IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for Open Previous Answer form.
+ """
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')])
@@ -1056,6 +1169,16 @@ class survey_question_wiz(osv.osv_memory):
}
def action_forward_next(self, cr, uid, ids, context=None):
+ """
+ Goes to Next Survey Answer.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of survey.question.wiz IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for Open Next Answer form.
+ """
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')])
@@ -1075,6 +1198,16 @@ class survey_question_wiz(osv.osv_memory):
}
def action_next(self, cr, uid, ids, context=None):
+ """
+ Goes to Next page.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of survey.question.wiz IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for Open Next survey.page form.
+ """
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')])
@@ -1090,6 +1223,16 @@ class survey_question_wiz(osv.osv_memory):
}
def action_previous(self, cr, uid, ids, context=None):
+ """
+ Goes to previous page.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of survey.question.wiz IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for Open Previous survey.page form.
+ """
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')])
@@ -1106,5 +1249,4 @@ class survey_question_wiz(osv.osv_memory):
survey_question_wiz()
-
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/survey/wizard/survey_browse_answer.py b/addons/survey/wizard/survey_browse_answer.py
index 120585c72a4..ba467bcea9a 100644
--- a/addons/survey/wizard/survey_browse_answer.py
+++ b/addons/survey/wizard/survey_browse_answer.py
@@ -26,8 +26,15 @@ from tools.translate import _
class survey_browse_answer(osv.osv_memory):
_name = 'survey.browse.answer'
-
def _get_survey(self, cr, uid, context=None):
+ """
+ Set the value in survey_id field,
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param context: A standard dictionary for contextual values,
+ @return : Tuple in list with values.
+ """
surv_obj = self.pool.get("survey")
surv_resp_obj = self.pool.get("survey.response")
result = []
@@ -42,6 +49,16 @@ class survey_browse_answer(osv.osv_memory):
}
def action_next(self, cr, uid, ids, context=None):
+ """
+ Open Browse Response wizard. if you select only survey_id then this wizard open with all response_ids and if you select survey_id and response_id then open the particular response of the survey.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of survey.browse.answer IDs,
+ @param context: A standard dictionary for contextual values,
+ @return : Dictionary value for Open the browse answer wizard.
+ """
record = self.read(cr, uid, ids, [])
record = record and record[0] or {}
if record['response_id']:
diff --git a/addons/survey/wizard/survey_print.py b/addons/survey/wizard/survey_print.py
new file mode 100644
index 00000000000..b4fb91441a1
--- /dev/null
+++ b/addons/survey/wizard/survey_print.py
@@ -0,0 +1,68 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved
+# $Id$
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from osv import fields, osv
+from tools.translate import _
+
+class survey_print(osv.osv_memory):
+ _name = 'survey.print'
+ _columns = {
+ 'orientation' : fields.selection([('vertical','Portrait(Vertical)'),('horizontal','Landscape(Horizontal)')], 'Orientation'),
+ 'paper_size' : fields.selection([('letter','Letter (8.5" x 11")'),('legal','Legal (8.5" x 14")'),('a4','A4 (210mm x 297mm)')], 'Paper Size'),
+ 'survey_title' : fields.boolean('Include Survey Title'),
+ 'page_number' : fields.boolean('Include Page Numvers'),
+ 'without_pagebreak' : fields.boolean('Print Without Page Breaks'),
+ }
+
+ _defaults = {
+ 'orientation': lambda *a:'vertical',
+ 'paper_size': lambda *a:'letter',
+ 'survey_title':lambda *a: 0,
+ 'page_number':lambda *a: 0,
+ 'without_pagebreak':lambda *a: 0
+ }
+
+ def action_next(self, cr, uid, ids, context=None):
+ """
+ Print Survey Form(print template of the survey).
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Survey IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for print survey form.
+ """
+ datas = {'ids' : context.get('active_ids', [])}
+ res = self.read(cr, uid, ids, ['survey_title', 'orientation', 'paper_size', 'page_number', 'without_pagebreak'], context)
+ res = res and res[0] or {}
+ datas['form'] = res
+ datas['model'] = 'survey.print'
+ return {
+ 'type':'ir.actions.report.xml',
+ 'report_name':'survey.form',
+ 'datas':datas,
+ }
+
+survey_print()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/survey/wizard/survey_print.xml b/addons/survey/wizard/survey_print.xml
new file mode 100644
index 00000000000..e5a42e17103
--- /dev/null
+++ b/addons/survey/wizard/survey_print.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+ Survey Print
+ survey.print
+ form
+
+
+
+
+
+
+
+
+ Print Survey
+ survey.print
+ form
+ form
+ new
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/survey/wizard/survey_print_answer.py b/addons/survey/wizard/survey_print_answer.py
index 3057836d559..ee4243ab2d5 100644
--- a/addons/survey/wizard/survey_print_answer.py
+++ b/addons/survey/wizard/survey_print_answer.py
@@ -41,6 +41,16 @@ class survey_print_answer(osv.osv_memory):
}
def action_next(self, cr, uid, ids, context=None):
+ """
+ Print Survey Answer in pdf format.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of print answer IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for created survey answer report
+ """
datas = {'ids' : context.get('active_ids', [])}
res = self.read(cr, uid, ids, ['response_ids', 'orientation', 'paper_size', 'page_number', 'without_pagebreak'], context)
res = res and res[0] or {}
diff --git a/addons/survey/wizard/survey_print_statistics.py b/addons/survey/wizard/survey_print_statistics.py
index 078f94878b0..55da0a99bfd 100644
--- a/addons/survey/wizard/survey_print_statistics.py
+++ b/addons/survey/wizard/survey_print_statistics.py
@@ -30,6 +30,16 @@ class survey_print_statistics(osv.osv_memory):
}
def action_next(self, cr, uid, ids, context=None):
+ """
+ Print Survey Statistics in pdf format.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Survey statistics IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for created survey statistics report
+ """
datas = {'ids' : context.get('active_ids', [])}
res = self.read(cr, uid, ids, ['survey_ids'], context)
res = res and res[0] or {}
diff --git a/addons/survey/wizard/survey_selection.py b/addons/survey/wizard/survey_selection.py
index 668ca8b63d9..5282eae794b 100644
--- a/addons/survey/wizard/survey_selection.py
+++ b/addons/survey/wizard/survey_selection.py
@@ -27,6 +27,16 @@ class survey_name_wiz(osv.osv_memory):
_name = 'survey.name.wiz'
def default_get(self, cr, uid, fields, context={}):
+ """
+ Set the default value in survey_id field. if open this wizard in survey form then set the default value in survey_id = active survey id.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param fields: List of Survey statistics IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for created survey statistics report
+ """
if not context:
context = {}
data = super(survey_name_wiz, self).default_get(cr, uid, fields, context)
@@ -35,6 +45,16 @@ class survey_name_wiz(osv.osv_memory):
return data
def _get_survey(self, cr, uid, context=None):
+ """
+ Set the value In survey_id field.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Survey statistics IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for created survey statistics report
+ """
surv_obj = self.pool.get("survey")
result = []
if context.has_key('survey_id'):
@@ -69,6 +89,16 @@ class survey_name_wiz(osv.osv_memory):
}
def action_next(self, cr, uid, ids, context=None):
+ """
+ Start the survey, Increment in started survey field but if set the max_response_limit of survey then check the current user how many times start this survey. if current user max_response_limit is reach then this user can not start this survey(Raise Exception).
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Survey IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary value for open survey question wizard.
+ """
survey_obj = self.pool.get('survey')
search_obj = self.pool.get('ir.ui.view')
@@ -100,6 +130,16 @@ class survey_name_wiz(osv.osv_memory):
}
def on_change_survey(self, cr, uid, ids, survey_id, context=None):
+ """
+ on change event of survey_id field, if note is available in selected survey then display this note in note fields.
+
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Survey IDs
+ @param context: A standard dictionary for contextual values
+ @return : Dictionary values of notes fields.
+ """
notes = self.pool.get('survey').read(cr, uid, survey_id, ['note'])['note']
return {'value': {'note' : notes}}
diff --git a/addons/survey/wizard/wizard_print_survey.py b/addons/survey/wizard/wizard_print_survey.py
deleted file mode 100644
index ec63726e3ef..00000000000
--- a/addons/survey/wizard/wizard_print_survey.py
+++ /dev/null
@@ -1,72 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved
-# $Id$
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-import wizard
-import time
-import pooler
-from random import choice
-import string
-import tools
-from tools.translate import _
-
-_survey_form = '''
-'''
-
-_survey_fields = {
- 'orientation':{
- 'string':"Orientation",
- 'type':'selection',
- 'selection':[('vertical','Portrait(Vertical)'),
- ('horizontal','Landscape(Horizontal)')],
- 'default': lambda *a:'vertical'},
- 'paper_size':{
- 'string':"Paper Size",
- 'type':'selection',
- 'selection':[('letter','Letter (8.5" x 11")'),
- ('legal','Legal (8.5" x 14")'),
- ('a4','A4 (210mm x 297mm)')],
- 'default': lambda *a:'letter'},
- 'survey_title': {'string':'Include Survey Title', 'type':'boolean', 'default':lambda *a: 0},
- 'page_number': {'string':'Include Page Numbers', 'type':'boolean', 'default':lambda *a: 0},
- 'without_pagebreak': {'string':'Print Without Page Breaks', 'type':'boolean', 'default':lambda *a: 0},
- }
-
-class print_survey_wizard(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'form', 'arch' :_survey_form, 'fields' :_survey_fields,\
- 'state' : [('end', 'Cancel', 'gtk-cancel'), ('print', 'Print', 'gtk-print')]}
- },
- 'print': {
- 'actions': [],
- 'result': {'type':'print', 'report':'survey.form', 'state':'end'}
- }
- }
-print_survey_wizard('wizard.print.survey')