From e2c90a5eee7edfae7c24ff13daf35dda6b3da8de Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Mon, 22 Mar 2010 17:47:16 +0530 Subject: [PATCH] [REVIEW]: code review bzr revid: mga@mga-20100322121716-uf3u13102vwcqps0 --- addons/survey/wizard/survey_answer.py | 50 ++++++++++++++++----------- addons/survey/wizard/survey_print.py | 42 +++++++++++----------- 2 files changed, 51 insertions(+), 41 deletions(-) diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index b8a1ce93266..4f8849079b0 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -1,3 +1,5 @@ + + # -*- encoding: utf-8 -*- ############################################################################## # @@ -19,16 +21,17 @@ # along with this program. If not, see . # ############################################################################## - -from osv import fields, osv +import os import datetime -from tools.translate import _ from lxml import etree -from tools import to_xml from time import strftime + import tools import netsvc -import os +from osv import osv +from osv import fields +from tools import to_xml +from tools.translate import _ class survey_question_wiz(osv.osv_memory): _name = 'survey.question.wiz' @@ -37,17 +40,19 @@ class survey_question_wiz(osv.osv_memory): } def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False): """ - Fields View Get method :- generate the new view and display the survey pages of selected survey. - - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param view_id : view id of the current object. - @param view_type : which type of view is create. like :- form, tree ,search etc... - @param context: A standard dictionary for contextual values - @return : Dictionary value for created view of particular survey pages. + Fields View Get method :- generate the new view and display the survey pages of selected survey. + + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param view_id : view id of the current object. + @param view_type : which type of view is create. like :- form, tree ,search etc... + @param context: A standard dictionary for contextual values + @return : Dictionary value for created view of particular survey pages. """ + result = super(survey_question_wiz, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu) + surv_name_wiz = self.pool.get('survey.name.wiz') survey_obj = self.pool.get('survey') page_obj = self.pool.get('survey.page') @@ -61,22 +66,25 @@ class survey_question_wiz(osv.osv_memory): wiz_id = 0 if not context.has_key('sur_name_id'): res_data = { - 'survey_id' : context.get('survey_id', False), - 'page_no' :-1, - 'page':'next', - 'transfer' :1, - 'response':0 + 'survey_id' : context.get('survey_id', False), + 'page_no' :-1, + 'page':'next', + 'transfer' :1, + 'response':0 } wiz_id = surv_name_wiz.create(cr, uid, res_data) + #TODO: change to the browse, use read if only need to read few columns values sur_name_rec = surv_name_wiz.read(cr, uid, wiz_id, []) context.update({'sur_name_id' :wiz_id}) else: - sur_name_rec = surv_name_wiz.read(cr, uid, context.get('sur_name_id',False)) + sur_name_rec = surv_name_wiz.read(cr, uid, context.get('sur_name_id', False)) if context.has_key('active_id'): context.pop('active_id') survey_id = context.get('survey_id', False) + #TODO: change to the browse, use read if only need to read few columns values + # this will fire select * from quary sur_rec = survey_obj.read(cr, uid, survey_id, []) p_id = sur_rec['page_ids'] total_pages = len(p_id) @@ -1249,4 +1257,4 @@ class survey_question_wiz(osv.osv_memory): survey_question_wiz() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/survey/wizard/survey_print.py b/addons/survey/wizard/survey_print.py index b4fb91441a1..ef82e1eaf87 100644 --- a/addons/survey/wizard/survey_print.py +++ b/addons/survey/wizard/survey_print.py @@ -1,3 +1,4 @@ + # -*- encoding: utf-8 -*- ############################################################################## # @@ -20,7 +21,8 @@ # ############################################################################## -from osv import fields, osv +from osv import osv +from osv import fields from tools.translate import _ class survey_print(osv.osv_memory): @@ -34,35 +36,35 @@ class survey_print(osv.osv_memory): } _defaults = { - 'orientation': lambda *a:'vertical', - 'paper_size': lambda *a:'letter', - 'survey_title':lambda *a: 0, - 'page_number':lambda *a: 0, - 'without_pagebreak':lambda *a: 0 + 'orientation': lambda *a:'vertical', + 'paper_size': lambda *a:'letter', + 'survey_title':lambda *a: 0, + 'page_number':lambda *a: 0, + 'without_pagebreak':lambda *a: 0 } def action_next(self, cr, uid, ids, context=None): """ - Print Survey Form(print template of the survey). - - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param ids: List of Survey IDs - @param context: A standard dictionary for contextual values - @return : Dictionary value for print survey form. + Print Survey Form(print template of the survey). + + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of Survey IDs + @param context: A standard dictionary for contextual values + @return : Dictionary value for print survey form. """ + datas = {'ids' : context.get('active_ids', [])} res = self.read(cr, uid, ids, ['survey_title', 'orientation', 'paper_size', 'page_number', 'without_pagebreak'], context) res = res and res[0] or {} datas['form'] = res datas['model'] = 'survey.print' return { - 'type':'ir.actions.report.xml', - 'report_name':'survey.form', - 'datas':datas, - } - + 'type':'ir.actions.report.xml', + 'report_name':'survey.form', + 'datas':datas, + } survey_print() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: