unknown
12 years ago
committed by
Stefan Rijnhart
5 changed files with 170 additions and 0 deletions
-
22view_groups_id/__init__.py
-
53view_groups_id/__openerp__.py
-
22view_groups_id/model/__init__.py
-
55view_groups_id/model/ir_ui_view.py
-
18view_groups_id/view/ir_ui_view.xml
@ -0,0 +1,22 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2013 Therp BV (<http://therp.nl>) |
|||
# All Rights Reserved |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
import model |
@ -0,0 +1,53 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2013 Therp BV (<http://therp.nl>) |
|||
# All Rights Reserved |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
{ |
|||
'name': 'group_ids for ir.ui.view', |
|||
'version': '1.0', |
|||
'description': """This addon is a backport of OpenERP 7.0's groups_id for |
|||
views. |
|||
|
|||
The greatness lies in the fact that with that, you can have specific |
|||
inherited views for specific groups, so you can radically change a view |
|||
for some groups without having to redefine any of the window actions |
|||
involved. |
|||
|
|||
Using it for 6.1 modules instead of fields_view_get hacks and the like |
|||
also lowers the effort it takes to port the module in question to 7.0 |
|||
""", |
|||
'author': ['Therp BV', 'OpenERP SA'], |
|||
'website': 'http://www.therp.nl', |
|||
"category": "Dependency", |
|||
"depends": [ |
|||
'base', |
|||
], |
|||
'css': [ |
|||
], |
|||
'data': [ |
|||
'view/ir_ui_view.xml', |
|||
], |
|||
'js': [ |
|||
], |
|||
'installable': True, |
|||
'active': False, |
|||
'certificate': '', |
|||
} |
@ -0,0 +1,22 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2013 Therp BV (<http://therp.nl>) |
|||
# All Rights Reserved |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
import ir_ui_view |
@ -0,0 +1,55 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2013 Therp BV (<http://therp.nl>) |
|||
# |
|||
# Code snippets from openobject-server 7.0 |
|||
# (C) 2004-2012 OpenERP S.A. (<http://openerp.com>) |
|||
# |
|||
# |
|||
# All Rights Reserved |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
from openerp.osv.orm import Model |
|||
from openerp.osv import fields |
|||
from openerp import SUPERUSER_ID |
|||
|
|||
|
|||
class ir_ui_view(Model): |
|||
_inherit = 'ir.ui.view' |
|||
|
|||
_columns = { |
|||
'groups_id': fields.many2many( |
|||
'res.groups', 'ir_ui_view_group_rel', 'view_id', 'group_id', |
|||
string='Groups', help="If this field is empty, the view " |
|||
"applies to all users. Otherwise, the view applies to the " |
|||
"users of those groups only."), |
|||
} |
|||
|
|||
def get_inheriting_views_arch(self, cr, uid, view_id, model, context=None): |
|||
user_groups = frozenset(self.pool.get('res.users').browse( |
|||
cr, SUPERUSER_ID, uid, context).groups_id) |
|||
|
|||
view_ids = [v[1] for v in |
|||
super(ir_ui_view, self).get_inheriting_views_arch( |
|||
cr, uid, view_id, model, context=context)] |
|||
|
|||
# filter views based on user groups |
|||
return [(view.arch, view.id) |
|||
for view in self.browse(cr, SUPERUSER_ID, view_ids, context) |
|||
if not (view.groups_id and |
|||
user_groups.isdisjoint(view.groups_id))] |
@ -0,0 +1,18 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
<record id="view_view_form" model="ir.ui.view"> |
|||
<field name="model">ir.ui.view</field> |
|||
<field name="inherit_id" ref="base.view_view_form" /> |
|||
<field name="arch" type="xml"> |
|||
<data> |
|||
<notebook position="inside"> |
|||
<page string="Groups"> |
|||
<field name="groups_id" nolabel="1" /> |
|||
</page> |
|||
</notebook> |
|||
</data> |
|||
</field> |
|||
</record> |
|||
</data> |
|||
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue