1
1
# -*- encoding: utf-8 -*-
2
2
#########################################################################
4
# Copyright (C) 2010 Sébastien Beau #
6
#This program is free software: you can redistribute it and/or modify #
7
#it under the terms of the GNU General Public License as published by #
8
#the Free Software Foundation, either version 3 of the License, or #
9
#(at your option) any later version. #
11
#This program is distributed in the hope that it will be useful, #
12
#but WITHOUT ANY WARRANTY; without even the implied warranty of #
13
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14
#GNU General Public License for more details. #
16
#You should have received a copy of the GNU General Public License #
17
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
4
# Base scheduler creator module for OpenERP
5
# Copyright (C) 2010 Sébastien Beau <sebastien.beau@akretion.com>
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.
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.
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/>.
18
20
#########################################################################
20
22
from osv import fields,osv
22
23
from tools.translate import _
24
class scheduler_creator_wizard(osv.osv):
25
class scheduler_creator_wizard(osv.osv_memory):
25
26
_name = 'scheduler.creator.wizard'
26
27
_description = 'scheduler creator wizard'
28
29
def action_create(self, cr, uid, id, context):
29
30
for id in context['active_ids']:
30
31
if context.get('object_link', False) and self.pool.get(context['object_link']).read(cr, uid, id, ['scheduler'], context)['scheduler']:
31
raise osv.except_osv(_('USER ERROR'), _('A scheduler already exist!!'))
32
raise osv.except_osv(_('USER ERROR'), _('A scheduler already exists !'))
33
34
vals = {'name':self.pool.get(context['object_link']).read(cr, uid, id, ['name'], context)['name'],
44
45
cron_id = self.pool.get('ir.cron').create(cr, uid, vals, context)
45
46
if context.get('object_link', False):
46
47
self.pool.get(context['object_link']).write(cr, uid, id, {'scheduler' : cron_id}, context)
47
return {'type': 'ir.actions.act_window_close'}
48
return {'type': 'ir.actions.act_window_close'}
49
50
scheduler_creator_wizard()