[IMP] survey :- add print_survey method to print surve form or survey answer.

bzr revid: ysa@tinyerp.co.in-20100408060047-ythm986g7igkdcbv
This commit is contained in:
Ysa (Open ERP)
2010-04-08 11:30:47 +05:30
parent 45256557dc
commit 95cfd5c87c
2 changed files with 42 additions and 2 deletions
+40
View File
@@ -95,6 +95,46 @@ class survey(osv.osv):
def copy(self, cr, uid, id, default=None,context={}):
raise osv.except_osv(_('Warning !'),_('You cannot duplicate the resource!'))
def action_print_survey(self, cr, uid, ids, context=None):
"""
If response is available then print this response otherwise 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.
"""
if not context:
context = {}
datas = {}
response_id = self.pool.get('survey.response').search(cr, uid, [('survey_id','=', ids)], context=context)
page_setting = {'orientation': 'vertical', 'without_pagebreak': 0, 'paper_size': 'letter', 'page_number': 1, 'survey_title': 1}
report = {}
datas['ids'] = ids
if response_id:
context.update({'survey_id': datas['ids']})
datas['form'] = page_setting
datas['model'] = 'survey.print.answer'
report = {
'type': 'ir.actions.report.xml',
'report_name': 'survey.browse.response',
'datas': datas,
'nodestroy': True,
'context' : context
}
else:
datas['form'] = page_setting
datas['model'] = 'survey.print'
report = {
'type': 'ir.actions.report.xml',
'report_name': 'survey.form',
'datas': datas,
'nodestroy':True,
'context' : context
}
return report
survey()
class survey_history(osv.osv):
+2 -2
View File
@@ -243,8 +243,8 @@
string="Answer Survey" type="action" icon="gtk-execute" context="{'survey_id': active_id}" attrs="{'invisible':[('state','!=','open')]}"/>
<button name="%(action_view_survey_question_message)d" states="open,draft,close,cancel"
string="Edit Survey" type="action" icon="gtk-edit" context="{'active':True,'edit' : True,'survey_id': active_id}"/>
<button name="%(survey_browse_response)d" states="open,draft,close,cancel"
string="Print Answer" type="action" icon="gtk-print"/>
<button name="action_print_survey" states="open,draft,close,cancel"
string="Print Answer" type="object" icon="gtk-print"/>
</tree>
</field>
</record>