1
##############################################################################
3
# Copyright (c) 2008-2012 Alistek Ltd (http://www.alistek.com) All Rights Reserved.
4
# General contacts <info@alistek.com>
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
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.
18
# This module is GPLv3 or newer and incompatible
19
# with OpenERP SA "AGPL + Private Use License"!
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.
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.
30
##############################################################################
34
from tools.translate import _
36
def ir_set(cr, uid, key, key2, name, models, value, replace=True, isobject=False, meta=None):
37
obj = pooler.get_pool(cr.dbname).get('ir.values')
38
return obj.set(cr, uid, key, key2, name, models, value, replace, isobject, meta)
44
class report_actions_wizard(wizard.interface):
48
form = '''<?xml version="1.0"?>
49
<form string="Add Print Button">
50
<!--<field name="print_button"/>-->
51
<field name="open_action"/>
54
exist_form = '''<?xml version="1.0"?>
55
<form string="Add Print Button">
56
<label string="Report Action already exist for this report."/>
59
exception_form = '''<?xml version="1.0"?>
60
<form string="Add Print Button">
61
<label string="Can not be create print button for the Special report."/>
64
done_form = '''<?xml version="1.0"?>
65
<form string="Remove print button">
66
<label string="The print button is successfully added"/>
70
'open_action': {'string': 'Open added action', 'type': 'boolean', 'default': False},
73
def _do_action(self, cr, uid, data, context):
74
pool = pooler.get_pool(cr.dbname)
75
report = pool.get(data['model']).browse(cr, uid, data['id'], context=context)
76
res = ir_set(cr, uid, 'action', 'client_print_multi', report.report_name, [report.model], 'ir.actions.report.xml,%d' % data['id'], isobject=True)
77
if report.report_wizard:
78
report._set_report_wizard()
79
return {'value_id':res[0]}
81
def _check(self, cr, uid, data, context):
82
pool = pooler.get_pool(cr.dbname)
83
ir_values_obj = pool.get('ir.values')
84
report = pool.get(data['model']).browse(cr, uid, data['id'], context=context)
85
if report.report_name in special_reports:
87
if report.report_wizard:
88
act_win_obj = pool.get('ir.actions.act_window')
89
act_win_ids = act_win_obj.search(cr, uid, [('res_model','=','aeroo.print_actions')], context=context)
90
for act_win in act_win_obj.browse(cr, uid, act_win_ids, context=context):
91
act_win_context = eval(act_win.context, {})
92
if act_win_context.get('report_action_id')==report.id:
96
ids = ir_values_obj.search(cr, uid, [('value','=',report.type+','+str(data['id']))])
102
def _action_open_window(self, cr, uid, data, context):
104
if not form['open_action']:
107
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
108
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
110
mod_id = mod_obj.search(cr, uid, [('name', '=', 'act_values_form_action')])[0]
111
res_id = mod_obj.read(cr, uid, mod_id, ['res_id'])['res_id']
112
act_win = act_obj.read(cr, uid, res_id, [])
113
act_win['domain'] = [('id','=',form['value_id'])]
114
act_win['name'] = _('Client Events')
120
'result': {'type':'choice','next_state':_check}
124
'result': {'type': 'form', 'arch': form, 'fields': fields, 'state': (('end', _('_Cancel')), ('process', _('_Ok')))},
128
'result': {'type': 'form', 'arch': exist_form, 'fields': {}, 'state': (('end', _('_Close')),)},
132
'result': {'type': 'form', 'arch': exception_form, 'fields': {}, 'state': (('end', _('_Close')),)},
135
'actions': [_do_action],
136
'result': {'type': 'state', 'state': 'done'},
140
'result': {'type': 'form', 'arch': done_form, 'fields': {}, 'state': (('exit', _('_Close')),)},
144
'result': {'type': 'action', 'action': _action_open_window, 'state': 'end'},
147
report_actions_wizard('aeroo.report_actions')