1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
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/>.
20 ##############################################################################
25 asset_end_arch = '''<?xml version="1.0"?>
26 <form string="Modify asset">
27 <separator string="Asset properties to modify" colspan="4"/>
28 <field name="name" colspan="4"/>
29 <field name="method_delay"/>
30 <field name="method_period"/>
31 <separator string="Notes" colspan="4"/>
32 <field name="note" nolabel="1" colspan="4"/>
36 'name': {'string':'Reason', 'type':'char', 'size':64, 'required':True},
37 'method_delay': {'string':'Number of interval', 'type':'float'},
38 'method_period': {'string':'Period per interval', 'type':'float'},
39 'note': {'string':'Notes', 'type':'text'},
42 def _asset_default(self, cr, uid, data, context={}):
43 pool = pooler.get_pool(cr.dbname)
44 prop = pool.get('account.asset.property').browse(cr, uid, data['id'], context)
47 'method_delay': prop.method_delay,
48 'method_period': prop.method_period
51 def _asset_modif(self, cr, uid, data, context={}):
52 pool = pooler.get_pool(cr.dbname)
53 prop = pool.get('account.asset.property').browse(cr, uid, data['id'], context)
54 pool.get('account.asset.property.history').create(cr, uid, {
55 'asset_property_id': data['id'],
57 'method_delay': prop.method_delay,
58 'method_period': prop.method_period,
59 'note': data['form']['note'],
61 pool.get('account.asset.property').write(cr, uid, [data['id']], {
62 'name': data['form']['name'],
63 'method_delay': data['form']['method_delay'],
64 'method_period': data['form']['method_period'],
69 class wizard_asset_modify(wizard.interface):
72 'actions': [_asset_default],
73 'result': {'type':'form', 'arch':asset_end_arch, 'fields':asset_end_fields, 'state':[
75 ('asset_modify','Modify asset')
79 'actions': [_asset_modif],
80 'result': {'type' : 'state', 'state': 'end'}
83 wizard_asset_modify('account.asset.modify')
86 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: