From 2a1bd62ed539a7613d04ed37ac631b8a8c2a6822 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Wed, 3 Oct 2012 11:18:46 +0530 Subject: [PATCH 01/19] [IMP] dialog after survey is completed says Complete Survey rename it to Survey Completed bzr revid: fka@tinyerp.com-20121003054846-6yy1eicqk5oqancq --- addons/survey/wizard/survey_answer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index 8ece1e184cf..76d2f012be8 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -435,7 +435,7 @@ class survey_question_wiz(osv.osv_memory): 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'}) From 38bca04309f47d2e13b8f26374efeb28d900da54 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Wed, 3 Oct 2012 11:37:49 +0530 Subject: [PATCH 02/19] [IMP] remove Survey Open Date field in survey bzr revid: fka@tinyerp.com-20121003060749-wr41pmtkfhdfdcr5 --- addons/survey/survey.py | 3 +-- addons/survey/survey_demo.xml | 3 --- addons/survey/survey_view.xml | 3 --- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/addons/survey/survey.py b/addons/survey/survey.py index d01140092d4..a996c4312ab 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -53,7 +53,6 @@ class survey(osv.osv): 'id': fields.integer('ID'), 'title': fields.char('Survey Title', size=128, required=1), 'page_ids': fields.one2many('survey.page', 'survey_id', 'Page'), - 'date_open': fields.datetime('Survey Open Date', readonly=1), 'date_close': fields.datetime('Survey Close Date', readonly=1), 'max_response_limit': fields.integer('Maximum Answer Limit', help="Set to one if survey is answerable only once"), @@ -80,7 +79,7 @@ class survey(osv.osv): } def survey_open(self, cr, uid, ids, arg): - self.write(cr, uid, ids, {'state': 'open', 'date_open': strftime("%Y-%m-%d %H:%M:%S")}) + self.write(cr, uid, ids, {'state': 'open'}) return True def survey_close(self, cr, uid, ids, arg): diff --git a/addons/survey/survey_demo.xml b/addons/survey/survey_demo.xml index 6f89095c699..f9a3e8f3159 100644 --- a/addons/survey/survey_demo.xml +++ b/addons/survey/survey_demo.xml @@ -17,7 +17,6 @@ 1 1 5 - @@ -166,7 +165,6 @@ 1 1 5 - @@ -633,7 +631,6 @@ 1 1 5 - diff --git a/addons/survey/survey_view.xml b/addons/survey/survey_view.xml index 01d6098df55..c71e4e8d537 100644 --- a/addons/survey/survey_view.xml +++ b/addons/survey/survey_view.xml @@ -220,7 +220,6 @@ - @@ -253,7 +252,6 @@ - @@ -295,7 +293,6 @@ - From 70d971c3d71ba0dd49cad49a3088e3b386b4bbf0 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Wed, 3 Oct 2012 12:04:32 +0530 Subject: [PATCH 03/19] [IMP] every field editable in survey when survey is in open state bzr revid: fka@tinyerp.com-20121003063432-nktuyqz1batgu0ne --- addons/survey/survey.py | 8 ++++---- addons/survey/survey_view.xml | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/survey/survey.py b/addons/survey/survey.py index a996c4312ab..999dec0aadc 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -60,10 +60,10 @@ class survey(osv.osv): help="Set to one if you require only one Answer per user"), 'state': fields.selection([('open', 'Open'), ('cancel', 'Cancelled'),('close', 'Closed') ], 'Status', readonly=True), 'responsible_id': fields.many2one('res.users', 'Responsible', help="User responsible for survey"), - 'tot_start_survey': fields.integer("Total Started Survey", readonly=1), - 'tot_comp_survey': fields.integer("Total Completed Survey", readonly=1), + 'tot_start_survey': fields.integer("Total Started Survey"), + 'tot_comp_survey': fields.integer("Total Completed Survey"), 'note': fields.text('Description', size=128), - 'history': fields.one2many('survey.history', 'survey_id', 'History Lines', readonly=True), + 'history': fields.one2many('survey.history', 'survey_id', 'History Lines'), 'users': fields.many2many('res.users', 'survey_users_rel', 'sid', 'uid', 'Users'), 'send_response': fields.boolean('Email Notification on Answer'), 'type': fields.many2one('survey.type', 'Type'), @@ -187,7 +187,7 @@ class survey_history(osv.osv): 'date': fields.datetime('Date started', readonly=1), } _defaults = { - 'date': lambda * a: datetime.datetime.now() + 'date': lambda * a: strftime("%Y-%m-%d %H:%M:%S") } survey_history() diff --git a/addons/survey/survey_view.xml b/addons/survey/survey_view.xml index c71e4e8d537..a03df6800e7 100644 --- a/addons/survey/survey_view.xml +++ b/addons/survey/survey_view.xml @@ -49,8 +49,8 @@ - - + + @@ -215,7 +215,7 @@ - + From 9f79e73ac88f12770cffb43b41d5f81fafc30db0 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Wed, 3 Oct 2012 12:53:48 +0530 Subject: [PATCH 04/19] [IMP] Add m2m_tags for Select Partne & change default mail subject in send invitation bzr revid: fka@tinyerp.com-20121003072348-lw76eoym8i3jdqcc --- addons/survey/wizard/survey_send_invitation.py | 4 ++-- addons/survey/wizard/survey_send_invitation.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/survey/wizard/survey_send_invitation.py b/addons/survey/wizard/survey_send_invitation.py index 5677a985e09..61e1dd23665 100644 --- a/addons/survey/wizard/survey_send_invitation.py +++ b/addons/survey/wizard/survey_send_invitation.py @@ -50,8 +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'] } @@ -75,6 +73,8 @@ class survey_send_invitation(osv.osv_memory): 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,''' + data['mail_subject'] = "Invitation for " + sur.title + data['mail_subject_existing'] = "Invitation for " + sur.title return data def create_report(self, cr, uid, res_ids, report_name=False, file_name=False): 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 @@ - + From 6ff616dd04e02303c855dc0a51b397810e9f8739 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Wed, 3 Oct 2012 14:50:43 +0530 Subject: [PATCH 05/19] [IMP] improve code bzr revid: fka@tinyerp.com-20121003092043-e3id1isgm65itoef --- addons/survey/survey.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 999dec0aadc..6e350ccf9ce 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -187,7 +187,7 @@ class survey_history(osv.osv): 'date': fields.datetime('Date started', readonly=1), } _defaults = { - 'date': lambda * a: strftime("%Y-%m-%d %H:%M:%S") + 'date': lambda * a: datetime.datetime.now() } survey_history() From f2ebee24e88f642dddfb339b00c8ca6f73467da1 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Wed, 3 Oct 2012 16:05:24 +0530 Subject: [PATCH 06/19] [IMP] improve code bzr revid: fka@tinyerp.com-20121003103524-j480eazwonxu1g4y --- addons/survey/wizard/survey_send_invitation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/survey/wizard/survey_send_invitation.py b/addons/survey/wizard/survey_send_invitation.py index 61e1dd23665..8c9bb2a7fbe 100644 --- a/addons/survey/wizard/survey_send_invitation.py +++ b/addons/survey/wizard/survey_send_invitation.py @@ -50,7 +50,6 @@ class survey_send_invitation(osv.osv_memory): _defaults = { 'send_mail': lambda *a: 1, 'send_mail_existing': lambda *a: 1, - 'mail_from': lambda *a: tools.config['email_from'] } def genpasswd(self): @@ -68,13 +67,14 @@ class survey_send_invitation(osv.osv_memory): name += "\t --> " + sur.title + "\n" if sur.state != 'open': msg += sur.title + "\n" + data['mail_subject'] = "Invitation for " + sur.title + data['mail_subject_existing'] = "Invitation for " + 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,''' - data['mail_subject'] = "Invitation for " + sur.title - data['mail_subject_existing'] = "Invitation for " + sur.title return data def create_report(self, cr, uid, res_ids, report_name=False, file_name=False): From 064d80917e76d52e133b6609cdc3ce3fbaf9d4f9 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Wed, 3 Oct 2012 17:19:46 +0530 Subject: [PATCH 07/19] [IMP] change old port 8080 bzr revid: fka@tinyerp.com-20121003114946-n25y3i5yx2s3bild --- addons/survey/wizard/survey_send_invitation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/survey/wizard/survey_send_invitation.py b/addons/survey/wizard/survey_send_invitation.py index 8c9bb2a7fbe..b6d68a47004 100644 --- a/addons/survey/wizard/survey_send_invitation.py +++ b/addons/survey/wizard/survey_send_invitation.py @@ -74,7 +74,7 @@ class survey_send_invitation(osv.osv_memory): 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,''' + \n link :- http://'''+ str(socket.gethostname()) + ''':8069 \n\n Thanks,''' return data def create_report(self, cr, uid, res_ids, report_name=False, file_name=False): From c2eb5616b7ed3ffb84ef1094b8296b20e5ab9174 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 4 Oct 2012 14:43:51 +0530 Subject: [PATCH 08/19] [IMP] improve code bzr revid: fka@tinyerp.com-20121004091351-sky1or0w62lqmf1d --- addons/survey/survey.py | 10 ++++++---- addons/survey/survey_demo.xml | 3 +++ addons/survey/survey_view.xml | 3 +++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 6e350ccf9ce..b3d38aeeb4d 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -53,6 +53,7 @@ class survey(osv.osv): 'id': fields.integer('ID'), 'title': fields.char('Survey Title', size=128, required=1), 'page_ids': fields.one2many('survey.page', 'survey_id', 'Page'), + 'date_open': fields.datetime('Survey Open Date', readonly=1), 'date_close': fields.datetime('Survey Close Date', readonly=1), 'max_response_limit': fields.integer('Maximum Answer Limit', help="Set to one if survey is answerable only once"), @@ -60,10 +61,10 @@ class survey(osv.osv): help="Set to one if you require only one Answer per user"), 'state': fields.selection([('open', 'Open'), ('cancel', 'Cancelled'),('close', 'Closed') ], 'Status', readonly=True), 'responsible_id': fields.many2one('res.users', 'Responsible', help="User responsible for survey"), - 'tot_start_survey': fields.integer("Total Started Survey"), - 'tot_comp_survey': fields.integer("Total Completed Survey"), + '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'), + 'history': fields.one2many('survey.history', 'survey_id', 'History Lines', readonly=True), 'users': fields.many2many('res.users', 'survey_users_rel', 'sid', 'uid', 'Users'), 'send_response': fields.boolean('Email Notification on Answer'), 'type': fields.many2one('survey.type', 'Type'), @@ -76,10 +77,11 @@ class survey(osv.osv): 'tot_comp_survey': lambda * a: 0, 'send_response': lambda * a: 1, 'response_user': lambda * a:1, + 'date_open': strftime("%Y-%m-%d %H:%M:%S"), } def survey_open(self, cr, uid, ids, arg): - self.write(cr, uid, ids, {'state': 'open'}) + self.write(cr, uid, ids, {'state': 'open', 'date_open': strftime("%Y-%m-%d %H:%M:%S")}) return True def survey_close(self, cr, uid, ids, arg): diff --git a/addons/survey/survey_demo.xml b/addons/survey/survey_demo.xml index f9a3e8f3159..6f89095c699 100644 --- a/addons/survey/survey_demo.xml +++ b/addons/survey/survey_demo.xml @@ -17,6 +17,7 @@ 1 1 5 + @@ -165,6 +166,7 @@ 1 1 5 + @@ -631,6 +633,7 @@ 1 1 5 + diff --git a/addons/survey/survey_view.xml b/addons/survey/survey_view.xml index a03df6800e7..e6d92b72ba1 100644 --- a/addons/survey/survey_view.xml +++ b/addons/survey/survey_view.xml @@ -220,6 +220,7 @@ + @@ -252,6 +253,7 @@ + @@ -293,6 +295,7 @@ + From 9dd89df9ce1132de0174ea56145237f9006787e8 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 4 Oct 2012 16:47:03 +0530 Subject: [PATCH 09/19] [IMP] make all fields readable in close state bzr revid: fka@tinyerp.com-20121004111703-nrzz774gjydu0oo8 --- addons/survey/survey_view.xml | 14 +++++++------- addons/survey/wizard/survey_answer.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/survey/survey_view.xml b/addons/survey/survey_view.xml index e6d92b72ba1..c0bf7d25b7b 100644 --- a/addons/survey/survey_view.xml +++ b/addons/survey/survey_view.xml @@ -38,15 +38,15 @@
- - - + + + @@ -55,7 +55,7 @@ - +
- +
- + diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index 76d2f012be8..5a027601446 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -429,7 +429,7 @@ 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')}) From f07e90b5cbfa0fbd8f8b57fa097bb5ba8f93a2cd Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 5 Oct 2012 11:08:34 +0530 Subject: [PATCH 10/19] [IMP] solve error When click on Edit Survey bzr revid: fka@tinyerp.com-20121005053834-62y619ae1xe10ojg --- addons/survey/wizard/survey_answer.py | 43 ++++++++++++++------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index 5a027601446..10ab4bf82da 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -112,26 +112,29 @@ class survey_question_wiz(osv.osv_memory): flag = False fields = {} if sur_name_read.page == "next" or sur_name_rec.page_no == -1: - if total_pages > sur_name_rec.page_no + 1: - if ((context.has_key('active') and not context.get('active', False)) \ - or not context.has_key('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 user_id=%s\ - and survey_id=%s', (uid,survey_id)) - res = cr.fetchone()[0] - user_limit = survey_obj.browse(cr, uid, survey_id) - user_limit = user_limit.response_user - if user_limit and res >= user_limit: - raise osv.except_osv(_('Warning!'),_("You cannot answer this survey more than %s times.") % (user_limit)) - - 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")}) - - 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}) - flag = True - page_number += 1 + if total_pages: + if total_pages > sur_name_rec.page_no + 1: + if ((context.has_key('active') and not context.get('active', False)) \ + or not context.has_key('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 user_id=%s\ + and survey_id=%s', (uid,survey_id)) + res = cr.fetchone()[0] + user_limit = survey_obj.browse(cr, uid, survey_id) + user_limit = user_limit.response_user + if user_limit and res >= user_limit: + raise osv.except_osv(_('Warning!'),_("You cannot answer this survey more than %s times.") % (user_limit)) + + 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")}) + + 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}) + flag = True + page_number += 1 + else: + raise osv.except_osv(_('Warning!'),_('This survey has no pages defined. Please define the pages first.')) if sur_name_rec.page_no > - 1: pre_button = True else: From dab351dcc7d8680b91ba99a235811958b41917dc Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 5 Oct 2012 11:53:07 +0530 Subject: [PATCH 11/19] [IMP] solve error When no pages define on test survey bzr revid: fka@tinyerp.com-20121005062307-er263zwe3mm9dgt3 --- addons/survey/survey.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/survey/survey.py b/addons/survey/survey.py index b3d38aeeb4d..809079eaedb 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -164,10 +164,14 @@ 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'] - context.update({'active':True,'survey_id': ids[0]}) + pages = sur['page_ids'] + if not pages: + raise osv.except_osv(_('Warning!'), _('This survey has no pages defined. Please define pages first.')) + else: + context.update({'active':True,'survey_id': ids[0]}) return { 'view_type': 'form', 'view_mode': 'form', From b2661913d4ae1ca15e558ed5b8310d78a0fcc4a2 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 5 Oct 2012 16:01:36 +0530 Subject: [PATCH 12/19] [IMP] solve error When no pages define in edit survey bzr revid: fka@tinyerp.com-20121005103136-ji9uo2h4eow9aqec --- addons/survey/wizard/survey_answer.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index 5a027601446..7e1417ecdb7 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: From 239690244363afd54eeea1c1f776f2dd113d54b2 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Tue, 9 Oct 2012 17:34:17 +0530 Subject: [PATCH 13/19] [IMP] improve code bzr revid: fka@tinyerp.com-20121009120417-ncg1zoqfnfkyi8cx --- addons/survey/wizard/survey_answer.py | 43 +++++++++++++-------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index a75a08cc974..7e1417ecdb7 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -112,29 +112,26 @@ class survey_question_wiz(osv.osv_memory): flag = False fields = {} if sur_name_read.page == "next" or sur_name_rec.page_no == -1: - if total_pages: - if total_pages > sur_name_rec.page_no + 1: - if ((context.has_key('active') and not context.get('active', False)) \ - or not context.has_key('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 user_id=%s\ - and survey_id=%s', (uid,survey_id)) - res = cr.fetchone()[0] - user_limit = survey_obj.browse(cr, uid, survey_id) - user_limit = user_limit.response_user - if user_limit and res >= user_limit: - raise osv.except_osv(_('Warning!'),_("You cannot answer this survey more than %s times.") % (user_limit)) - - 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")}) - - 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}) - flag = True - page_number += 1 - else: - raise osv.except_osv(_('Warning!'),_('This survey has no pages defined. Please define the pages first.')) + if total_pages > sur_name_rec.page_no + 1: + if ((context.has_key('active') and not context.get('active', False)) \ + or not context.has_key('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 user_id=%s\ + and survey_id=%s', (uid,survey_id)) + res = cr.fetchone()[0] + user_limit = survey_obj.browse(cr, uid, survey_id) + user_limit = user_limit.response_user + if user_limit and res >= user_limit: + raise osv.except_osv(_('Warning!'),_("You cannot answer this survey more than %s times.") % (user_limit)) + + 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")}) + + 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}) + flag = True + page_number += 1 if sur_name_rec.page_no > - 1: pre_button = True else: From 6e4eca2ba7571bf7a90235e6020ff5314db933c3 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 12 Oct 2012 18:30:00 +0530 Subject: [PATCH 14/19] [FIX] traceback:ValueError: too many values to unpack bzr revid: fka@tinyerp.com-20121012130000-qtd29ab755kuszsc --- addons/survey/wizard/survey_send_invitation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/survey/wizard/survey_send_invitation.py b/addons/survey/wizard/survey_send_invitation.py index b6d68a47004..4c2840b787d 100644 --- a/addons/survey/wizard/survey_send_invitation.py +++ b/addons/survey/wizard/survey_send_invitation.py @@ -176,7 +176,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'), From f1a881236b2c525a47ae99a9723a8ce00807b62e Mon Sep 17 00:00:00 2001 From: Amit Patel Date: Thu, 18 Oct 2012 12:26:40 +0530 Subject: [PATCH 15/19] [IMP]:improved config parameter while sending invitation bzr revid: apa@tinyerp.com-20121018065640-chr285k3tcnk2bho --- addons/survey/wizard/survey_send_invitation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/survey/wizard/survey_send_invitation.py b/addons/survey/wizard/survey_send_invitation.py index 4c2840b787d..661c9417180 100644 --- a/addons/survey/wizard/survey_send_invitation.py +++ b/addons/survey/wizard/survey_send_invitation.py @@ -74,7 +74,7 @@ class survey_send_invitation(osv.osv_memory): 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()) + ''':8069 \n\n Thanks,''' + \n '''+ self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url', default='http://localhost:8069', context=context) + '''\n\n Thanks,''' return data def create_report(self, cr, uid, res_ids, report_name=False, file_name=False): From f57cc2402d2df0b1512c3f8aeeb5ba01024436ba Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Tue, 23 Oct 2012 16:47:46 +0200 Subject: [PATCH 16/19] [IMP] survey: code review bzr revid: qdp-launchpad@openerp.com-20121023144746-aidxyhxho59irw2d --- addons/survey/survey.py | 6 ++---- addons/survey/survey_view.xml | 2 +- addons/survey/wizard/survey_answer.py | 4 ++-- addons/survey/wizard/survey_send_invitation.py | 15 ++++++++++----- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 809079eaedb..3b406484d43 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -152,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', @@ -170,8 +169,7 @@ class survey(osv.osv): pages = sur['page_ids'] if not pages: raise osv.except_osv(_('Warning!'), _('This survey has no pages defined. Please define pages first.')) - else: - context.update({'active':True,'survey_id': ids[0]}) + context.update({'active':True,'survey_id': ids[0]}) return { 'view_type': 'form', 'view_mode': 'form', diff --git a/addons/survey/survey_view.xml b/addons/survey/survey_view.xml index ef3366ee1ee..c01e8b45ce2 100644 --- a/addons/survey/survey_view.xml +++ b/addons/survey/survey_view.xml @@ -215,7 +215,7 @@ - + diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index 7e1417ecdb7..f1a96fa154a 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -153,9 +153,9 @@ class survey_question_wiz(osv.osv_memory): if pag_rec: title = pag_rec.title note = pag_rec.note - question_ids=pag_rec.question_ids + question_ids = pag_rec.question_ids else: - title=sur_rec.title + 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}) diff --git a/addons/survey/wizard/survey_send_invitation.py b/addons/survey/wizard/survey_send_invitation.py index 661c9417180..dd0d6157caf 100644 --- a/addons/survey/wizard/survey_send_invitation.py +++ b/addons/survey/wizard/survey_send_invitation.py @@ -67,14 +67,19 @@ class survey_send_invitation(osv.osv_memory): name += "\t --> " + sur.title + "\n" if sur.state != 'open': msg += sur.title + "\n" - data['mail_subject'] = "Invitation for " + sur.title - data['mail_subject_existing'] = "Invitation for " + sur.title + 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 '''+ self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url', default='http://localhost:8069', context=context) + '''\n\n Thanks,''' + data['mail'] = _(''' +Hello %(name)s, \n\n +Please find hereby a survey that we would like you to fill: %s\n +You can access this survey with the following parameters: + Your login ID: %(login)s,\n + Your password: %(passwd)s\n +%s\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): From a94b8b432f5e044f155d2ef0a68911b739084595 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Tue, 23 Oct 2012 17:17:40 +0200 Subject: [PATCH 17/19] [FIX] survey: syntax error bzr revid: qdp-launchpad@openerp.com-20121023151740-wjft48qjgffasaug --- addons/survey/wizard/survey_send_invitation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/survey/wizard/survey_send_invitation.py b/addons/survey/wizard/survey_send_invitation.py index dd0d6157caf..a75cae2f893 100644 --- a/addons/survey/wizard/survey_send_invitation.py +++ b/addons/survey/wizard/survey_send_invitation.py @@ -68,7 +68,7 @@ class survey_send_invitation(osv.osv_memory): 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_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) From b8756e66062d5c1c209861ccc8dee9ab8e8c1f7c Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Tue, 23 Oct 2012 20:32:57 +0200 Subject: [PATCH 18/19] [FIX] survey: 'format requires mapping' error fixed bzr revid: qdp-launchpad@openerp.com-20121023183257-hzl1ed9nhkci7348 --- addons/survey/wizard/survey_send_invitation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/survey/wizard/survey_send_invitation.py b/addons/survey/wizard/survey_send_invitation.py index a75cae2f893..51b652a2d13 100644 --- a/addons/survey/wizard/survey_send_invitation.py +++ b/addons/survey/wizard/survey_send_invitation.py @@ -71,13 +71,13 @@ class survey_send_invitation(osv.osv_memory): 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) + raise osv.except_osv(_('Warning!'), _('The following surveys are not in open state: %s') % msg) data['mail'] = _(''' -Hello %(name)s, \n\n +Hello %%(name)s, \n\n Please find hereby a survey that we would like you to fill: %s\n You can access this survey with the following parameters: - Your login ID: %(login)s,\n - Your password: %(passwd)s\n + Your login ID: %%(login)s,\n + Your password: %%(passwd)s\n %s\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 From 9c712d53365c5d1e4885b33ff2eb7ac2156ca691 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 24 Oct 2012 00:33:58 +0200 Subject: [PATCH 19/19] [IMP] survey: code review bzr revid: qdp-launchpad@openerp.com-20121023223358-vqey57o52eyi6fhf --- addons/survey/survey.py | 2 +- addons/survey/wizard/survey_send_invitation.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 3b406484d43..b57f778a5cc 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -77,7 +77,7 @@ class survey(osv.osv): 'tot_comp_survey': lambda * a: 0, 'send_response': lambda * a: 1, 'response_user': lambda * a:1, - 'date_open': strftime("%Y-%m-%d %H:%M:%S"), + 'date_open': fields.datetime.now, } def survey_open(self, cr, uid, ids, arg): diff --git a/addons/survey/wizard/survey_send_invitation.py b/addons/survey/wizard/survey_send_invitation.py index 51b652a2d13..936e3363bde 100644 --- a/addons/survey/wizard/survey_send_invitation.py +++ b/addons/survey/wizard/survey_send_invitation.py @@ -64,7 +64,7 @@ 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) @@ -74,11 +74,12 @@ class survey_send_invitation(osv.osv_memory): raise osv.except_osv(_('Warning!'), _('The following surveys are not in open state: %s') % msg) data['mail'] = _(''' Hello %%(name)s, \n\n -Please find hereby a survey that we would like you to fill: %s\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: - Your login ID: %%(login)s,\n + URL: %s + Your login ID: %%(login)s\n Your password: %%(passwd)s\n -%s\n\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