~chris-ormaza/aeroo/openerp6

« back to all changes in this revision

Viewing changes to report_aeroo/wizard/report_print_by_action.py

  • Committer: root
  • Date: 2011-11-15 11:01:45 UTC
  • Revision ID: root@erp.kndati.lv-20111115110145-ybiy32im1hnvoby7
RC6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##############################################################################
 
2
#
 
3
# Copyright (c) 2008-2011 Alistek Ltd (http://www.alistek.com) All Rights Reserved.
 
4
#                    General contacts <info@alistek.com>
 
5
#
 
6
# WARNING: This program as such is intended to be used by professional
 
7
# programmers who take the whole responsability of assessing all potential
 
8
# consequences resulting from its eventual inadequacies and bugs
 
9
# End users who are looking for a ready-to-use solution with commercial
 
10
# garantees and support are strongly adviced to contract a Free Software
 
11
# Service Company
 
12
#
 
13
# This program is Free Software; you can redistribute it and/or
 
14
# modify it under the terms of the GNU General Public License
 
15
# as published by the Free Software Foundation; either version 3
 
16
# of the License, or (at your option) any later version.
 
17
#
 
18
# This module is GPLv3 or newer and incompatible
 
19
# with OpenERP SA "AGPL + Private Use License"!
 
20
#
 
21
# This program is distributed in the hope that it will be useful,
 
22
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
23
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
24
# GNU General Public License for more details.
 
25
#
 
26
# You should have received a copy of the GNU General Public License
 
27
# along with this program; if not, write to the Free Software
 
28
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
29
#
 
30
##############################################################################
 
31
 
 
32
 
 
33
from osv import osv
 
34
from osv import fields
 
35
 
 
36
class report_print_by_action(osv.osv_memory):
 
37
    _name = 'aeroo.print_by_action'
 
38
 
 
39
    def to_print(self, cr, uid, ids, context=None):
 
40
        this = self.browse(cr, uid, ids[0], context=context)
 
41
        report_xml = self.pool.get(context['active_model']).browse(cr, uid, context['active_id'], context=context)
 
42
        print_ids = eval("[%s]" % this.object_ids, {})
 
43
        data = {'model':report_xml.model, 'ids':print_ids, 'id':print_ids[0], 'report_type': 'aeroo'}
 
44
        return {
 
45
            'type': 'ir.actions.report.xml',
 
46
            'report_name': report_xml.report_name,
 
47
            'datas': data,
 
48
            'context':context
 
49
        }
 
50
    
 
51
    _columns = {
 
52
        'name':fields.text('Object Model', readonly=True),
 
53
        'object_ids':fields.char('Object IDs', size=250, required=True, help="Comma separated records ID"),
 
54
                
 
55
    }
 
56
 
 
57
    def _get_model(self, cr, uid, context):
 
58
        return self.pool.get(context['active_model']).read(cr, uid, context['active_id'], ['model'], context=context)['model']
 
59
 
 
60
    _defaults = {
 
61
        'name': _get_model,
 
62
    }
 
63
 
 
64
report_print_by_action()
 
65