[FIX] survey: correctly cast selection fields to int, properly use a relation table for many2many fields.
bzr revid: vmt@openerp.com-20110824093527-e8u4d410zof48vpm
This commit is contained in:
@@ -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})
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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"),
|
||||
}
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user