~openerp-commiter/openobject-addons/extra-6.0

« back to all changes in this revision

Viewing changes to base_scheduler_creator/schedulder_creator.py

  • Committer: Albert Cervera i Areny
  • Date: 2011-06-14 09:51:35 UTC
  • mfrom: (5345.1.165 openobject-addons)
  • Revision ID: albert@nan-tic.com-20110614095135-1x3p6tmil5lxkl9b
Merge and add nan_remove_default_filters

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- encoding: utf-8 -*-
2
2
#########################################################################
3
 
#                                                                       #
4
 
# Copyright (C) 2010   Sébastien Beau                                   #
5
 
#                                                                       #
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.                                    #
10
 
#                                                                       #
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.                           #
15
 
#                                                                       #
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/>.  #
 
3
#
 
4
#    Base scheduler creator module for OpenERP
 
5
#    Copyright (C) 2010  Sébastien Beau <sebastien.beau@akretion.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
#
18
20
#########################################################################
19
21
 
20
22
from osv import fields,osv
21
 
import os
22
23
from tools.translate import _
23
24
 
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'
27
28
    
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 !'))
32
33
            
33
34
            vals = {'name':self.pool.get(context['object_link']).read(cr, uid, id, ['name'], context)['name'],
34
35
                    'active':False,
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'}
48
49
 
49
50
scheduler_creator_wizard()