[fix] mail: double clicking on post on the chatter
[odoo/odoo.git] / addons / survey / wizard / survey_print_answer.py
1 # -*- encoding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-TODAY OpenERP S.A. <http://www.openerp.com>
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21
22 from openerp.osv import fields, osv
23 from openerp.tools.translate import _
24
25 class survey_print_answer(osv.osv_memory):
26     _name = 'survey.print.answer'
27     _columns = {
28         'response_ids': fields.many2many('survey.response','survey_print_response',\
29                             'response_id','print_id', "Answer", required="1"),
30         'orientation': fields.selection([('vertical','Portrait(Vertical)'),\
31                             ('horizontal','Landscape(Horizontal)')], 'Orientation'),
32         'paper_size': fields.selection([('letter','Letter (8.5" x 11")'),\
33                             ('legal','Legal (8.5" x 14")'),\
34                             ('a4','A4 (210mm x 297mm)')], 'Paper Size'),
35         'page_number': fields.boolean('Include Page Number'),
36         'without_pagebreak': fields.boolean('Print Without Page Breaks')
37     }
38
39     _defaults = {
40         'orientation': lambda *a:'vertical',
41         'paper_size': lambda *a:'letter',
42         'page_number': lambda *a: 0,
43         'without_pagebreak': lambda *a: 0
44     }
45
46     def action_next(self, cr, uid, ids, context=None):
47         """
48         Print Survey Answer in pdf format.
49
50         @param self: The object pointer
51         @param cr: the current row, from the database cursor,
52         @param uid: the current user’s ID for security checks,
53         @param ids: List of print answer IDs
54         @param context: A standard dictionary for contextual values
55         @return : Dictionary value for created survey answer report
56         """
57         if context is None:
58             context = {}
59         datas = {'ids': context.get('active_ids', [])}
60         res = self.read(cr, uid, ids, ['response_ids', 'orientation', 'paper_size',\
61                              'page_number', 'without_pagebreak'], context=context)
62         res = res and res[0] or {}
63         datas['form'] = res
64         datas['model'] = 'survey.print.answer'
65         return {
66             'type': 'ir.actions.report.xml',
67             'report_name': 'survey.browse.response',
68             'datas': datas,
69         }
70
71 survey_print_answer()
72
73 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: