1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2011 TeMPO Consulting, MSF
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
##############################################################################
23
from osv import fields
25
from tools.translate import _
28
class fixed_asset_setup(osv.osv_memory):
29
_name = 'fixed.asset.setup'
30
_inherit = 'res.config'
33
'fixed_asset_ok': fields.boolean(string='Is the system manage Fixed assets ?'),
36
def default_get(self, cr, uid, fields, context=None):
38
Display the default value for fixed asset
40
setup_id = self.pool.get('unifield.setup.configuration').get_config(cr, uid)
41
res = super(fixed_asset_setup, self).default_get(cr, uid, fields, context=context)
43
res['fixed_asset_ok'] = setup_id.fixed_asset_ok
48
def execute(self, cr, uid, ids, context=None):
50
Fill the fixed_asset_ok field and active/de-activate the feature
52
assert len(ids) == 1, "We should only get one object from the form"
53
payload = self.browse(cr, uid, ids[0], context=context)
55
setup_obj = self.pool.get('unifield.setup.configuration')
56
setup_id = setup_obj.get_config(cr, uid)
58
setup_obj.write(cr, uid, [setup_id.id], {'fixed_asset_ok': payload.fixed_asset_ok}, context=context)