1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
26 from tools.translate import _
28 info = '''<?xml version="1.0"?>
29 <form string="Distribution Model Saved">
30 <label string="This distribution model has been saved.\nYou will be able to reuse it later."/>
34 def activate(self, cr, uid, data, context):
35 plan_obj = pooler.get_pool(cr.dbname).get('account.analytic.plan.instance')
37 plan = plan_obj.browse(cr, uid, data['id'], context)
38 if (not plan.name) or (not plan.code):
39 raise wizard.except_wizard(_('Error'), _('Please put a name and a code before saving the model !'))
40 pids = pooler.get_pool(cr.dbname).get('account.analytic.plan').search(cr, uid, [], context=context)
42 raise wizard.except_wizard(_('Error'), _('No analytic plan defined !'))
43 plan_obj.write(cr,uid,[data['id']],{'plan_id':pids[0]})
48 def _do_nothing(self, cr, uid, data, context):
51 class create_model(wizard.interface):
56 'result': {'type':'choice','next_state':activate}
60 'result': {'type':'form', 'arch':info, 'fields':{}, 'state':[('end','OK')]}
64 'result': {'type':'action','action':_do_nothing , 'state':'end'} #FIXME: check
67 create_model('create.model')
70 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: