From b657bea06f94a22e6370601571e77f913e329a92 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Wed, 24 Aug 2011 11:35:27 +0200 Subject: [PATCH] [FIX] survey: correctly cast selection fields to int, properly use a relation table for many2many fields. bzr revid: vmt@openerp.com-20110824093527-e8u4d410zof48vpm --- addons/survey/wizard/survey_answer.py | 5 +++-- addons/survey/wizard/survey_print.py | 2 +- addons/survey/wizard/survey_print_statistics.py | 2 +- addons/survey/wizard/survey_selection.py | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index 896bde70d3c..140e934af87 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -600,8 +600,9 @@ class survey_question_wiz(osv.osv_memory): if not sur_name_read['store_ans']: his_id = self.pool.get('survey.history').create(cr, uid, {'user_id': uid, \ 'date': strftime('%Y-%m-%d %H:%M:%S'), 'survey_id': sur_name_read['survey_id']}) - sur_rec = survey_obj.read(cr, uid, sur_name_read['survey_id']) - survey_obj.write(cr, uid, sur_name_read['survey_id'], {'tot_start_survey' : sur_rec['tot_start_survey'] + 1}) + survey_id = int(sur_name_read['survey_id']) # This is a selection field (a string). + 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.has_key('request') and context.get('request',False): self.pool.get(context.get('object',False)).write(cr, uid, [int(context.get('cur_id',False))], {'response' : response_id}) diff --git a/addons/survey/wizard/survey_print.py b/addons/survey/wizard/survey_print.py index 87767f34a68..4592bd38b6e 100644 --- a/addons/survey/wizard/survey_print.py +++ b/addons/survey/wizard/survey_print.py @@ -27,7 +27,7 @@ from tools.translate import _ class survey_print(osv.osv_memory): _name = 'survey.print' _columns = { - 'survey_ids': fields.many2many('survey','survey_print',\ + 'survey_ids': fields.many2many('survey','survey_print_survey_rel',\ 'survey_id','print_id', "Survey", required="1"), 'orientation' : fields.selection([('vertical','Portrait(Vertical)'),\ ('horizontal','Landscape(Horizontal)')], 'Orientation'), diff --git a/addons/survey/wizard/survey_print_statistics.py b/addons/survey/wizard/survey_print_statistics.py index 10b321fcf45..57a05910966 100644 --- a/addons/survey/wizard/survey_print_statistics.py +++ b/addons/survey/wizard/survey_print_statistics.py @@ -26,7 +26,7 @@ from tools.translate import _ class survey_print_statistics(osv.osv_memory): _name = 'survey.print.statistics' _columns = { - 'survey_ids': fields.many2many('survey','survey_print_statistics','survey_id',\ + 'survey_ids': fields.many2many('survey','survey_print_statistics_survey_rel','survey_id',\ 'print_id', "Survey", required="1"), } diff --git a/addons/survey/wizard/survey_selection.py b/addons/survey/wizard/survey_selection.py index 8d613c74bd0..0809254b8a7 100644 --- a/addons/survey/wizard/survey_selection.py +++ b/addons/survey/wizard/survey_selection.py @@ -64,7 +64,7 @@ class survey_name_wiz(osv.osv_memory): survey_user_group_id = self.pool.get('res.groups').search(cr, uid, [('name', '=', 'Survey / User')]) group_id = self.pool.get('res.groups').search(cr, uid, [('name', 'in', ('Tools / Manager','Tools / User','Survey / User'))]) user_obj = self.pool.get('res.users') - user_rec = user_obj.read(cr, uid, uid) + user_rec = user_obj.read(cr, uid, uid, ['groups_id', 'survey_id'], context) if survey_user_group_id: if survey_user_group_id == user_rec['groups_id']: for sur in surv_obj.browse(cr, uid, surv_obj.search(cr, uid, [])): @@ -123,7 +123,7 @@ class survey_name_wiz(osv.osv_memory): if context is None: context = {} this = self.browse(cr, uid, ids, context=context)[0] - survey_id = this.survey_id + survey_id = int(this.survey_id) # This is a selection field (a string). 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))