2
# -*- encoding: utf-8 -*-
3
##############################################################################
5
# OpenERP, Open Source Management Solution
6
# Copyright (C) 2011 TeMPO Consulting, MSF. All Rights Reserved
7
# Developer: Max Mumford
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU Affero General Public License as
11
# published by the Free Software Foundation, either version 3 of the
12
# License, or (at your option) any later version.
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU Affero General Public License for more details.
19
# You should have received a copy of the GNU Affero General Public License
20
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
##############################################################################
25
from osv import fields
27
def _join_dictionary(dict, key_prefix, value_prefix, seperator):
30
for k, v in dict.items():
31
s += key_prefix + str(k) + value_prefix + str(v) + seperator
34
class view_config_install(osv.osv_memory):
35
_name = 'msf_button_access_rights.view_config_wizard_install'
36
_inherit = 'res.config'
38
def execute(self, cr, uid, ids, context=None):
40
Perform a write (With no updated values) on each view in the database to trigger the Button Access Rule create / update process. Keep a log of all errors and return a new wizard showing the results.
42
context = context or {}
44
view_pool = self.pool.get('ir.ui.view')
45
view_ids = view_pool.search(cr, uid, [])
49
view_pool.write(cr, uid, id, {})
50
except Exception as e:
53
all = self.pool.get('msf_button_access_rights.button_access_rule').search(cr, 1, [])
56
'successes': str(len(view_ids) - len(errors)) + ' Views were processed successfully',
57
'total': 'You now have ' + str(len(all)) + ' Button Access Rules in total',
58
'errors': str(len(errors)) + ' error(s) occurred while processing the Views\n\n' + _join_dictionary(errors, 'View ID: ', ', Error: ', '\n')
61
results_id = self.pool.get('msf_button_access_rights.view_config_wizard_install_results').create(cr, 1, results, context=context)
63
'name': 'Generation Results',
66
'res_model': 'msf_button_access_rights.view_config_wizard_install_results',
67
'res_id' : results_id,
68
'type': 'ir.actions.act_window',
75
class view_config_install_results(osv.osv_memory):
76
_name = 'msf_button_access_rights.view_config_wizard_install_results'
78
'successes': fields.text('Successes', readonly=True),
79
'total': fields.text('Total', readonly=True),
80
'errors': fields.text('Errors', readonly=True),
83
view_config_install_results()
b'\\ No newline at end of file'