| Answer Create Date:- |
- # *-* formatting hard coded, breaks with utf8
- """ + to_xml(time.strftime('%d-%m-%Y %I:%M:%S %p', time.strptime(response.date_create.split('.')[0], '%Y-%m-%d %H:%M:%S'))) + """ |
+ """ + to_xml(resp_create) + """ |
|
Answer By:- |
""" + to_xml(response.user_id.login or '') + """ |
diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py
index 4d623b4b6ac..f803ab88803 100644
--- a/addons/survey/wizard/survey_answer.py
+++ b/addons/survey/wizard/survey_answer.py
@@ -1,21 +1,20 @@
-# -*- encoding: utf-8 -*-
+## -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved
-# $Id$
+# 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 General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# it under the terms of the GNU Affero 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.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
##############################################################################
@@ -78,31 +77,42 @@ class survey_question_wiz(osv.osv_memory):
sur_name_rec = surv_name_wiz.browse(cr, uid, wiz_id)
context.update({'sur_name_id' :wiz_id})
else:
- sur_name_rec = surv_name_wiz.browse(cr, uid, context.get('sur_name_id', False))
+ sur_name_rec = surv_name_wiz.browse(cr, uid, context['sur_name_id'])
if context.has_key('active_id'):
context.pop('active_id')
survey_id = context.get('survey_id', False)
if not survey_id:
- return {}
+ # Try one more time to find it
+ if sur_name_rec.survey_id:
+ survey_id = sur_name_rec.survey_id[0]
+ else:
+ # raise osv.except_osv(_('Error!'), _("Cannot locate survey for the question wizard!"))
+ # If this function is called without a survey_id in
+ # its context, it makes no sense to return any view.
+ # Just return the default, empty view for this object,
+ # in order to please random calls to this fn().
+ 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)
p_id = map(lambda x:x.id, sur_rec.page_ids)
total_pages = len(p_id)
pre_button = False
readonly = 0
- if context.has_key('response_id') and context.get('response_id', False) \
+ if context.get('response_id', False) \
and int(context['response_id'][0]) > 0:
readonly = 1
if not sur_name_rec.page_no + 1 :
- surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)], {'store_ans':{}})
+ surv_name_wiz.write(cr, uid, [context['sur_name_id'],], {'store_ans':{}})
- sur_name_read = surv_name_wiz.browse(cr, uid, context.get('sur_name_id',False))
+ sur_name_read = surv_name_wiz.browse(cr, uid, context['sur_name_id'])
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.get('sur_name_id', False)], {'transfer':False})
+ surv_name_wiz.write(cr, uid, [context['sur_name_id']], {'transfer':False})
flag = False
fields = {}
if sur_name_read.page == "next" or sur_name_rec.page_no == -1:
@@ -123,7 +133,7 @@ class survey_question_wiz(osv.osv_memory):
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.get('sur_name_id', False)], {'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:
@@ -131,7 +141,7 @@ 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.get('sur_name_id', False)],\
+ surv_name_wiz.write(cr, uid, [context['sur_name_id'],],\
{'page_no' : sur_name_rec.page_no - 1})
flag = True
page_number -= 1
@@ -144,6 +154,7 @@ class survey_question_wiz(osv.osv_memory):
xml_group = etree.SubElement(xml_form, 'group', {'col': '1', 'colspan': '4'})
if context.has_key('response_id') and context.get('response_id', False) \
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.user_id.name + ', Date :- ' + record.date_create.split('.')[0] )), 'align':"0.0"})
diff --git a/addons/survey/wizard/survey_selection.py b/addons/survey/wizard/survey_selection.py
index 0f7ca8628f0..2ef83d38fcf 100644
--- a/addons/survey/wizard/survey_selection.py
+++ b/addons/survey/wizard/survey_selection.py
@@ -27,7 +27,7 @@ from tools.translate import _
class survey_name_wiz(osv.osv_memory):
_name = 'survey.name.wiz'
- def default_get(self, cr, uid, fields, context={}):
+ def default_get(self, cr, uid, fields, context=None):
"""
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.
@@ -38,7 +38,7 @@ class survey_name_wiz(osv.osv_memory):
@param context: A standard dictionary for contextual values
@return : Dictionary value for created survey statistics report
"""
- if not context:
+ if context is None:
context = {}
data = super(survey_name_wiz, self).default_get(cr, uid, fields, context)
if context.has_key('survey_id'):
@@ -75,7 +75,7 @@ class survey_name_wiz(osv.osv_memory):
u_list.append(use.id)
if uid in u_list:
result.append((sur.id, sur.title))
- return result
+ return result
for sur in surv_obj.browse(cr, uid, surv_obj.search(cr, uid, [])):
if sur.state == 'open':
res = False
diff --git a/addons/survey/wizard/survey_send_invitation.py b/addons/survey/wizard/survey_send_invitation.py
index 8c61a9b4393..62be63dc755 100644
--- a/addons/survey/wizard/survey_send_invitation.py
+++ b/addons/survey/wizard/survey_send_invitation.py
@@ -1,22 +1,21 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved
-# $Id$
+# 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 General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# it under the terms of the GNU Affero 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.
+# GNU Affero 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 .
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see
#
##############################################################################