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 vat_setup(osv.osv_memory):
30
_inherit = 'res.config'
33
'vat_ok': fields.boolean(string='Do you manage VAT locally ?'),
36
def default_get(self, cr, uid, fields, context=None):
38
Display the default value for delivery process
40
setup_id = self.pool.get('unifield.setup.configuration').get_config(cr, uid)
41
res = super(vat_setup, self).default_get(cr, uid, fields, context=context)
42
res['vat_ok'] = setup_id.vat_ok
47
def execute(self, cr, uid, ids, context=None):
49
Fill the vats_ok field and active/de-activate menu entries
51
assert len(ids) == 1, "We should only get one object from the form"
52
payload = self.browse(cr, uid, ids[0], context=context)
54
setup_obj = self.pool.get('unifield.setup.configuration')
55
data_obj = self.pool.get('ir.model.data')
57
setup_id = setup_obj.get_config(cr, uid)
59
# Get all menu ids concerned by this modification
60
taxes_menu_id = data_obj.get_object_reference(cr, uid, 'account', 'next_id_27')[1]
62
menu_ids = [taxes_menu_id]
65
# If the feature is not activate, inactive the menu entries
66
self.pool.get('ir.ui.menu').write(cr, uid, menu_ids, {'active': True}, context=context)
68
self.pool.get('ir.ui.menu').write(cr, uid, menu_ids, {'active': False}, context=context)
70
setup_obj.write(cr, uid, [setup_id.id], {'vat_ok': payload.vat_ok}, context=context)