13
13
# This program is Free Software; you can redistribute it and/or
14
14
# modify it under the terms of the GNU General Public License
15
# as published by the Free Software Foundation; either version 2
15
# as published by the Free Software Foundation; either version 3
16
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"!
18
21
# This program is distributed in the hope that it will be useful,
19
22
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
23
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32
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)
34
40
special_reports = [
64
#'print_button': {'string': 'Add print button', 'type': 'boolean', 'default': True, 'help':'Add action to menu context in print button.'},
65
70
'open_action': {'string': 'Open added action', 'type': 'boolean', 'default': False},
68
73
def _do_action(self, cr, uid, data, context):
69
74
pool = pooler.get_pool(cr.dbname)
70
75
report = pool.get(data['model']).browse(cr, uid, data['id'], context=context)
71
#if data['form']['print_button']:
72
76
res = ir.ir_set(cr, uid, 'action', 'client_print_multi', report.report_name, [report.model], 'ir.actions.report.xml,%d' % data['id'], isobject=True)
74
# res = ir.ir_set(cr, uid, 'action', 'client_print_multi', report.report_name, [report.model,0], 'ir.actions.report.xml,%d' % data['id'], isobject=True)
77
if report.report_wizard:
78
report._set_report_wizard()
75
79
return {'value_id':res[0]}
77
81
def _check(self, cr, uid, data, context):
78
82
pool = pooler.get_pool(cr.dbname)
83
ir_values_obj = pool.get('ir.values')
79
84
report = pool.get(data['model']).browse(cr, uid, data['id'], context=context)
80
85
if report.report_name in special_reports:
82
ids = pool.get('ir.values').search(cr, uid, [('value','=',report.type+','+str(data['id']))])
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']))])
88
102
def _action_open_window(self, cr, uid, data, context):
90
104
if not form['open_action']:
93
'domain':"[('id','=',%d)]" % (form['value_id']),
94
'name': _('Client Actions Connections'),
96
'view_mode': 'tree,form',
97
'res_model': 'ir.values',
99
'type': 'ir.actions.act_window',
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')