diff --git a/addons/survey/survey.py b/addons/survey/survey.py index d01140092d4..b57f778a5cc 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -77,6 +77,7 @@ class survey(osv.osv): 'tot_comp_survey': lambda * a: 0, 'send_response': lambda * a: 1, 'response_user': lambda * a:1, + 'date_open': fields.datetime.now, } def survey_open(self, cr, uid, ids, arg): @@ -151,8 +152,7 @@ class survey(osv.osv): pages = sur['page_ids'] if not pages: raise osv.except_osv(_('Warning!'), _('This survey has no question defined. Please define the questions and answers first.')) - else: - context.update({'active':False,'survey_id': ids[0]}) + context.update({'active':False,'survey_id': ids[0]}) return { 'view_type': 'form', 'view_mode': 'form', @@ -163,9 +163,12 @@ class survey(osv.osv): 'context': context } def test_survey(self, cr, uid, ids, context=None): - sur_obj = self.read(cr, uid, ids,['title'], context=context) + sur_obj = self.read(cr, uid, ids,['title','page_ids'], context=context) for sur in sur_obj: name = sur['title'] + pages = sur['page_ids'] + if not pages: + raise osv.except_osv(_('Warning!'), _('This survey has no pages defined. Please define pages first.')) context.update({'active':True,'survey_id': ids[0]}) return { 'view_type': 'form', diff --git a/addons/survey/survey_view.xml b/addons/survey/survey_view.xml index 0247a205700..c01e8b45ce2 100644 --- a/addons/survey/survey_view.xml +++ b/addons/survey/survey_view.xml @@ -38,24 +38,24 @@
- - - + + + - - + + - +
- +
diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index 8ece1e184cf..f1a96fa154a 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -134,6 +134,8 @@ class survey_question_wiz(osv.osv_memory): page_number += 1 if sur_name_rec.page_no > - 1: pre_button = True + else: + flag = True else: if sur_name_rec.page_no != 0: p_id = p_id[sur_name_rec.page_no - 1] @@ -146,7 +148,15 @@ class survey_question_wiz(osv.osv_memory): pre_button = True if flag: pag_rec = page_obj.browse(cr, uid, p_id, context=context) - xml_form = etree.Element('form', {'string': tools.ustr(pag_rec.title or sur_rec.title)}) + note = False + question_ids = [] + if pag_rec: + title = pag_rec.title + note = pag_rec.note + question_ids = pag_rec.question_ids + else: + title = sur_rec.title + xml_form = etree.Element('form', {'string': tools.ustr(title)}) if context.has_key('active') and context.get('active',False) and context.has_key('edit'): 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'}) @@ -174,10 +184,10 @@ class survey_question_wiz(osv.osv_memory): 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.note: - for que_test in pag_rec.note.split('\n'): + if note: + for que_test in note.split('\n'): etree.SubElement(xml_form, 'label', {'string': to_xml(tools.ustr(que_test)), 'align':"0.0"}) - que_ids = pag_rec.question_ids + que_ids = question_ids qu_no = 0 for que in que_ids: @@ -429,13 +439,13 @@ class survey_question_wiz(osv.osv_memory): vals['attachment_ids'] = [(0,0,{'name': a_name, 'datas_fname': a_name, 'datas': str(a_content).encode('base64')}) - for a_name, a_content in attachments] + for a_name, a_content in attachments.items()] self.pool.get('mail.mail').create(cr, uid, vals, context=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'}) - etree.SubElement(xml_form, 'separator', {'string': 'Complete Survey', 'colspan': "4"}) + 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') etree.SubElement(xml_footer, 'button', {'special':"cancel",'string':"OK",'colspan':"2",'class':'oe_highlight'}) diff --git a/addons/survey/wizard/survey_send_invitation.py b/addons/survey/wizard/survey_send_invitation.py index 5677a985e09..936e3363bde 100644 --- a/addons/survey/wizard/survey_send_invitation.py +++ b/addons/survey/wizard/survey_send_invitation.py @@ -50,9 +50,6 @@ class survey_send_invitation(osv.osv_memory): _defaults = { 'send_mail': lambda *a: 1, 'send_mail_existing': lambda *a: 1, - 'mail_subject': lambda *a: "Invitation", - 'mail_subject_existing': lambda *a: "Invitation", - 'mail_from': lambda *a: tools.config['email_from'] } def genpasswd(self): @@ -67,14 +64,23 @@ class survey_send_invitation(osv.osv_memory): msg = "" name = "" for sur in survey_obj.browse(cr, uid, context.get('active_ids', []), context=context): - name += "\t --> " + sur.title + "\n" + name += "\n --> " + sur.title + "\n" if sur.state != 'open': msg += sur.title + "\n" + data['mail_subject'] = _("Invitation for %s") % (sur.title) + data['mail_subject_existing'] = _("Invitation for %s") % (sur.title) + data['mail_from'] = sur.responsible_id.email if msg: - raise osv.except_osv(_('Warning!'), _('%sSurvey is not in open state') % msg) - data['mail'] = '''Hello %(name)s, \n\n We are inviting you for following survey. \ - \n ''' + name + '''\n Your login ID: %(login)s, Your password: %(passwd)s - \n link :- http://'''+ str(socket.gethostname()) + ''':8080 \n\n Thanks,''' + raise osv.except_osv(_('Warning!'), _('The following surveys are not in open state: %s') % msg) + data['mail'] = _(''' +Hello %%(name)s, \n\n +Would you please spent some of your time to fill-in our survey: \n%s\n +You can access this survey with the following parameters: + URL: %s + Your login ID: %%(login)s\n + Your password: %%(passwd)s\n +\n\n +Thanks,''') % (name, self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url', default='http://localhost:8069', context=context)) return data def create_report(self, cr, uid, res_ids, report_name=False, file_name=False): @@ -176,7 +182,7 @@ class survey_send_invitation(osv.osv_memory): vals['attachment_ids'] = [(0,0,{'name': a_name, 'datas_fname': a_name, 'datas': str(a_content).encode('base64')}) - for a_name, a_content in attachments] + for a_name, a_content in attachments.items()] ans = self.pool.get('mail.mail').create(cr, uid, vals, context=context) if ans: res_data = {'name': partner.name or _('Unknown'), diff --git a/addons/survey/wizard/survey_send_invitation.xml b/addons/survey/wizard/survey_send_invitation.xml index 340cb58b5cf..a611973d772 100644 --- a/addons/survey/wizard/survey_send_invitation.xml +++ b/addons/survey/wizard/survey_send_invitation.xml @@ -16,7 +16,7 @@ - +