Holger Brunn
6 years ago
13 changed files with 0 additions and 598 deletions
-
30auth_dynamic_groups/README.rst
-
21auth_dynamic_groups/__init__.py
-
39auth_dynamic_groups/__manifest__.py
-
67auth_dynamic_groups/i18n/de.po
-
67auth_dynamic_groups/i18n/es.po
-
67auth_dynamic_groups/i18n/fr.po
-
68auth_dynamic_groups/i18n/pt_BR.po
-
68auth_dynamic_groups/i18n/sl.po
-
22auth_dynamic_groups/model/__init__.py
-
63auth_dynamic_groups/model/res_groups.py
-
55auth_dynamic_groups/model/res_users.py
-
BINauth_dynamic_groups/static/description/icon.png
-
31auth_dynamic_groups/view/res_groups.xml
@ -1,30 +0,0 @@ |
|||||
Description |
|
||||
----------- |
|
||||
This module allows defining groups whose membership is a condition expressed as |
|
||||
python code. For every user, it is evaluated during login if she belongs to |
|
||||
the group or not. |
|
||||
|
|
||||
Usage |
|
||||
----- |
|
||||
Check `Dynamic` on a group you want to be dynamic. Now fill in the condition, |
|
||||
using `user` which is a browse record of the user in question that evaluates |
|
||||
truthy if the user is supposed to be a member of the group and falsy if not. |
|
||||
|
|
||||
There is a constraint on the field to check for validity if this expression. |
|
||||
When you're satisfied, click the button `Evaluate` to prefill the group's |
|
||||
members. The condition will be checked now for every user who logs in. |
|
||||
|
|
||||
Example |
|
||||
------- |
|
||||
We have a group called `Amsterdam` and want it to contain all users from |
|
||||
city of Amsterdam. So we use the membership condition |
|
||||
|
|
||||
``` |
|
||||
user.partner_id.city == 'Amsterdam' |
|
||||
``` |
|
||||
|
|
||||
Now we can be sure every user living in this city is in the right group, and we |
|
||||
can start assigning local menus to it, adjust permissions, etc. Keep in mind |
|
||||
that view overrides can also be restricted by a group id, this gives a lot of |
|
||||
possibilities to dynamically adapt views based on arbitrary properties |
|
||||
reachable via the user record. |
|
@ -1,21 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
############################################################################## |
|
||||
# |
|
||||
# OpenERP, Open Source Management Solution |
|
||||
# This module copyright (C) 2013 Therp BV (<http://therp.nl>). |
|
||||
# |
|
||||
# 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 . import model |
|
@ -1,39 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
############################################################################## |
|
||||
# |
|
||||
# OpenERP, Open Source Management Solution |
|
||||
# This module copyright (C) 2013-2015 Therp BV (<http://therp.nl>). |
|
||||
# |
|
||||
# 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": "Dynamic groups", |
|
||||
"version": "8.0.1.0.0", |
|
||||
"author": "Therp BV", |
|
||||
"complexity": "normal", |
|
||||
'summary': 'Have membership conditions for certain groups', |
|
||||
"category": "Tools", |
|
||||
"depends": [ |
|
||||
'base', |
|
||||
], |
|
||||
"data": [ |
|
||||
'view/res_groups.xml', |
|
||||
], |
|
||||
"auto_install": False, |
|
||||
'installable': False, |
|
||||
"external_dependencies": { |
|
||||
'python': [], |
|
||||
}, |
|
||||
} |
|
@ -1,67 +0,0 @@ |
|||||
# Translation of Odoo Server. |
|
||||
# This file contains the translation of the following modules: |
|
||||
# * auth_dynamic_groups |
|
||||
# |
|
||||
# Translators: |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: server-tools (8.0)\n" |
|
||||
"Report-Msgid-Bugs-To: \n" |
|
||||
"POT-Creation-Date: 2015-09-29 11:14+0000\n" |
|
||||
"PO-Revision-Date: 2015-09-18 13:53+0000\n" |
|
||||
"Last-Translator: <>\n" |
|
||||
"Language-Team: German (http://www.transifex.com/oca/OCA-server-tools-8-0/language/de/)\n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: \n" |
|
||||
"Language: de\n" |
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: model:ir.model,name:auth_dynamic_groups.model_res_groups |
|
||||
msgid "Access Groups" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: field:res.groups,dynamic_group_condition:0 |
|
||||
msgid "Condition" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: field:res.groups,is_dynamic:0 |
|
||||
msgid "Dynamic" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: view:res.groups:auth_dynamic_groups.view_groups_form |
|
||||
msgid "Evaluate" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: view:res.groups:auth_dynamic_groups.view_groups_form |
|
||||
msgid "Fill in your condition..." |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: code:addons/auth_dynamic_groups/model/res_groups.py:57 |
|
||||
#, python-format |
|
||||
msgid "The condition doesn't evaluate correctly!" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: help:res.groups,dynamic_group_condition:0 |
|
||||
msgid "" |
|
||||
"The condition to be met for a user to be a member of this group. It is " |
|
||||
"evaluated as python code at login time, you get `user` passed as a browse " |
|
||||
"record" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: model:ir.model,name:auth_dynamic_groups.model_res_users |
|
||||
msgid "Users" |
|
||||
msgstr "Benutzer" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: view:res.groups:auth_dynamic_groups.view_groups_form |
|
||||
msgid "{'readonly': [('is_dynamic', '=', True)]}" |
|
||||
msgstr "" |
|
@ -1,67 +0,0 @@ |
|||||
# Translation of Odoo Server. |
|
||||
# This file contains the translation of the following modules: |
|
||||
# * auth_dynamic_groups |
|
||||
# |
|
||||
# Translators: |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: server-tools (8.0)\n" |
|
||||
"Report-Msgid-Bugs-To: \n" |
|
||||
"POT-Creation-Date: 2015-09-29 11:14+0000\n" |
|
||||
"PO-Revision-Date: 2015-09-18 13:53+0000\n" |
|
||||
"Last-Translator: <>\n" |
|
||||
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-server-tools-8-0/language/es/)\n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: \n" |
|
||||
"Language: es\n" |
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: model:ir.model,name:auth_dynamic_groups.model_res_groups |
|
||||
msgid "Access Groups" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: field:res.groups,dynamic_group_condition:0 |
|
||||
msgid "Condition" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: field:res.groups,is_dynamic:0 |
|
||||
msgid "Dynamic" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: view:res.groups:auth_dynamic_groups.view_groups_form |
|
||||
msgid "Evaluate" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: view:res.groups:auth_dynamic_groups.view_groups_form |
|
||||
msgid "Fill in your condition..." |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: code:addons/auth_dynamic_groups/model/res_groups.py:57 |
|
||||
#, python-format |
|
||||
msgid "The condition doesn't evaluate correctly!" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: help:res.groups,dynamic_group_condition:0 |
|
||||
msgid "" |
|
||||
"The condition to be met for a user to be a member of this group. It is " |
|
||||
"evaluated as python code at login time, you get `user` passed as a browse " |
|
||||
"record" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: model:ir.model,name:auth_dynamic_groups.model_res_users |
|
||||
msgid "Users" |
|
||||
msgstr "Usuarios" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: view:res.groups:auth_dynamic_groups.view_groups_form |
|
||||
msgid "{'readonly': [('is_dynamic', '=', True)]}" |
|
||||
msgstr "" |
|
@ -1,67 +0,0 @@ |
|||||
# Translation of Odoo Server. |
|
||||
# This file contains the translation of the following modules: |
|
||||
# * auth_dynamic_groups |
|
||||
# |
|
||||
# Translators: |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: server-tools (8.0)\n" |
|
||||
"Report-Msgid-Bugs-To: \n" |
|
||||
"POT-Creation-Date: 2015-09-29 11:14+0000\n" |
|
||||
"PO-Revision-Date: 2015-09-18 13:53+0000\n" |
|
||||
"Last-Translator: <>\n" |
|
||||
"Language-Team: French (http://www.transifex.com/oca/OCA-server-tools-8-0/language/fr/)\n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: \n" |
|
||||
"Language: fr\n" |
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: model:ir.model,name:auth_dynamic_groups.model_res_groups |
|
||||
msgid "Access Groups" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: field:res.groups,dynamic_group_condition:0 |
|
||||
msgid "Condition" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: field:res.groups,is_dynamic:0 |
|
||||
msgid "Dynamic" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: view:res.groups:auth_dynamic_groups.view_groups_form |
|
||||
msgid "Evaluate" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: view:res.groups:auth_dynamic_groups.view_groups_form |
|
||||
msgid "Fill in your condition..." |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: code:addons/auth_dynamic_groups/model/res_groups.py:57 |
|
||||
#, python-format |
|
||||
msgid "The condition doesn't evaluate correctly!" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: help:res.groups,dynamic_group_condition:0 |
|
||||
msgid "" |
|
||||
"The condition to be met for a user to be a member of this group. It is " |
|
||||
"evaluated as python code at login time, you get `user` passed as a browse " |
|
||||
"record" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: model:ir.model,name:auth_dynamic_groups.model_res_users |
|
||||
msgid "Users" |
|
||||
msgstr "Utilisateurs" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: view:res.groups:auth_dynamic_groups.view_groups_form |
|
||||
msgid "{'readonly': [('is_dynamic', '=', True)]}" |
|
||||
msgstr "" |
|
@ -1,68 +0,0 @@ |
|||||
# Translation of Odoo Server. |
|
||||
# This file contains the translation of the following modules: |
|
||||
# * auth_dynamic_groups |
|
||||
# |
|
||||
# Translators: |
|
||||
# Armando Vulcano Junior <vulcano@uol.com.br>, 2015 |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: server-tools (8.0)\n" |
|
||||
"Report-Msgid-Bugs-To: \n" |
|
||||
"POT-Creation-Date: 2015-09-29 11:14+0000\n" |
|
||||
"PO-Revision-Date: 2015-09-18 20:45+0000\n" |
|
||||
"Last-Translator: Armando Vulcano Junior <vulcano@uol.com.br>\n" |
|
||||
"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/OCA-server-tools-8-0/language/pt_BR/)\n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: \n" |
|
||||
"Language: pt_BR\n" |
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: model:ir.model,name:auth_dynamic_groups.model_res_groups |
|
||||
msgid "Access Groups" |
|
||||
msgstr "Grupos de Acesso" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: field:res.groups,dynamic_group_condition:0 |
|
||||
msgid "Condition" |
|
||||
msgstr "Condição" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: field:res.groups,is_dynamic:0 |
|
||||
msgid "Dynamic" |
|
||||
msgstr "Dinâmico" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: view:res.groups:auth_dynamic_groups.view_groups_form |
|
||||
msgid "Evaluate" |
|
||||
msgstr "Avaliar" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: view:res.groups:auth_dynamic_groups.view_groups_form |
|
||||
msgid "Fill in your condition..." |
|
||||
msgstr "Preencha na sua condição..." |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: code:addons/auth_dynamic_groups/model/res_groups.py:57 |
|
||||
#, python-format |
|
||||
msgid "The condition doesn't evaluate correctly!" |
|
||||
msgstr "Condição não avalia corretamente!" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: help:res.groups,dynamic_group_condition:0 |
|
||||
msgid "" |
|
||||
"The condition to be met for a user to be a member of this group. It is " |
|
||||
"evaluated as python code at login time, you get `user` passed as a browse " |
|
||||
"record" |
|
||||
msgstr "A condição a ser cumprida para um usuário ser um membro deste grupo. É avaliado como código python no momento do login, você pega `user` passado como um registro de procura" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: model:ir.model,name:auth_dynamic_groups.model_res_users |
|
||||
msgid "Users" |
|
||||
msgstr "Usuários" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: view:res.groups:auth_dynamic_groups.view_groups_form |
|
||||
msgid "{'readonly': [('is_dynamic', '=', True)]}" |
|
||||
msgstr "{'readonly': [('is_dynamic', '=', True)]}" |
|
@ -1,68 +0,0 @@ |
|||||
# Translation of Odoo Server. |
|
||||
# This file contains the translation of the following modules: |
|
||||
# * auth_dynamic_groups |
|
||||
# |
|
||||
# Translators: |
|
||||
# Matjaž Mozetič <m.mozetic@matmoz.si>, 2015 |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: server-tools (8.0)\n" |
|
||||
"Report-Msgid-Bugs-To: \n" |
|
||||
"POT-Creation-Date: 2015-09-29 11:14+0000\n" |
|
||||
"PO-Revision-Date: 2015-09-24 11:47+0000\n" |
|
||||
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n" |
|
||||
"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-server-tools-8-0/language/sl/)\n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: \n" |
|
||||
"Language: sl\n" |
|
||||
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: model:ir.model,name:auth_dynamic_groups.model_res_groups |
|
||||
msgid "Access Groups" |
|
||||
msgstr "Dostopne skupine" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: field:res.groups,dynamic_group_condition:0 |
|
||||
msgid "Condition" |
|
||||
msgstr "Pogoj" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: field:res.groups,is_dynamic:0 |
|
||||
msgid "Dynamic" |
|
||||
msgstr "Dinamične" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: view:res.groups:auth_dynamic_groups.view_groups_form |
|
||||
msgid "Evaluate" |
|
||||
msgstr "Ovrednoti" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: view:res.groups:auth_dynamic_groups.view_groups_form |
|
||||
msgid "Fill in your condition..." |
|
||||
msgstr "Izpolnite svoj pogoj..." |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: code:addons/auth_dynamic_groups/model/res_groups.py:57 |
|
||||
#, python-format |
|
||||
msgid "The condition doesn't evaluate correctly!" |
|
||||
msgstr "Pogoj se ne ovrednoti pravilno!" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: help:res.groups,dynamic_group_condition:0 |
|
||||
msgid "" |
|
||||
"The condition to be met for a user to be a member of this group. It is " |
|
||||
"evaluated as python code at login time, you get `user` passed as a browse " |
|
||||
"record" |
|
||||
msgstr "Pogoj, ki ga mora uporabnik izpolniti, da bi bil član te skupine. Ovrednoten je kot python koda ob prijavi. Uporabnik je spuščen kot brskalni zapis." |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: model:ir.model,name:auth_dynamic_groups.model_res_users |
|
||||
msgid "Users" |
|
||||
msgstr "Uporabniki" |
|
||||
|
|
||||
#. module: auth_dynamic_groups |
|
||||
#: view:res.groups:auth_dynamic_groups.view_groups_form |
|
||||
msgid "{'readonly': [('is_dynamic', '=', True)]}" |
|
||||
msgstr "{'readonly': [('is_dynamic', '=', True)]}" |
|
@ -1,22 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
############################################################################## |
|
||||
# |
|
||||
# OpenERP, Open Source Management Solution |
|
||||
# This module copyright (C) 2013 Therp BV (<http://therp.nl>). |
|
||||
# |
|
||||
# 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 . import res_users |
|
||||
from . import res_groups |
|
@ -1,63 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
############################################################################## |
|
||||
# |
|
||||
# OpenERP, Open Source Management Solution |
|
||||
# This module copyright (C) 2013 Therp BV (<http://therp.nl>). |
|
||||
# |
|
||||
# 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 import models, fields, api, exceptions |
|
||||
from openerp.tools.safe_eval import safe_eval |
|
||||
from openerp import _ |
|
||||
|
|
||||
|
|
||||
class res_groups(models.Model): |
|
||||
_inherit = 'res.groups' |
|
||||
|
|
||||
is_dynamic = fields.Boolean('Dynamic') |
|
||||
dynamic_group_condition = fields.Text( |
|
||||
'Condition', help='The condition to be met for a user to be a ' |
|
||||
'member of this group. It is evaluated as python code at login ' |
|
||||
'time, you get `user` passed as a browse record') |
|
||||
|
|
||||
@api.multi |
|
||||
def eval_dynamic_group_condition(self, uid=None): |
|
||||
user = self.env['res.users'].browse([uid]) if uid else self.env.user |
|
||||
result = all( |
|
||||
self.mapped( |
|
||||
lambda this: safe_eval( |
|
||||
this.dynamic_group_condition or 'False', |
|
||||
{ |
|
||||
'user': user.sudo(), |
|
||||
'any': any, |
|
||||
'all': all, |
|
||||
'filter': filter, |
|
||||
}))) |
|
||||
return result |
|
||||
|
|
||||
@api.multi |
|
||||
@api.constrains('dynamic_group_condition') |
|
||||
def _check_dynamic_group_condition(self): |
|
||||
try: |
|
||||
self.filtered('is_dynamic').eval_dynamic_group_condition() |
|
||||
except (NameError, SyntaxError, TypeError): |
|
||||
raise exceptions.ValidationError( |
|
||||
_('The condition doesn\'t evaluate correctly!')) |
|
||||
|
|
||||
@api.multi |
|
||||
def action_evaluate(self): |
|
||||
res_users = self.env['res.users'] |
|
||||
for user in res_users.search([]): |
|
||||
res_users.update_dynamic_groups(user.id, self.env.cr.dbname) |
|
@ -1,55 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
############################################################################## |
|
||||
# |
|
||||
# OpenERP, Open Source Management Solution |
|
||||
# This module copyright (C) 2013 Therp BV (<http://therp.nl>). |
|
||||
# |
|
||||
# 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.models import Model |
|
||||
from openerp.modules.registry import RegistryManager |
|
||||
from openerp import SUPERUSER_ID |
|
||||
|
|
||||
|
|
||||
class res_users(Model): |
|
||||
_inherit = 'res.users' |
|
||||
|
|
||||
def _login(self, db, login, password): |
|
||||
uid = super(res_users, self)._login(db, login, password) |
|
||||
|
|
||||
if uid: |
|
||||
self.update_dynamic_groups(uid, db) |
|
||||
|
|
||||
return uid |
|
||||
|
|
||||
def update_dynamic_groups(self, uid, db): |
|
||||
pool = RegistryManager.get(db) |
|
||||
cr = pool._db.cursor() |
|
||||
user = pool.get('res.users').browse(cr, SUPERUSER_ID, uid) |
|
||||
groups_obj = pool.get('res.groups') |
|
||||
user.write( |
|
||||
{ |
|
||||
'groups_id': [ |
|
||||
(4, dynamic_group.id) |
|
||||
if dynamic_group.eval_dynamic_group_condition(uid=uid) |
|
||||
else (3, dynamic_group.id) |
|
||||
for dynamic_group in groups_obj.browse( |
|
||||
cr, SUPERUSER_ID, |
|
||||
groups_obj.search(cr, SUPERUSER_ID, |
|
||||
[('is_dynamic', '=', True)])) |
|
||||
], |
|
||||
}) |
|
||||
cr.commit() |
|
||||
cr.close() |
|
Before Width: 128 | Height: 128 | Size: 9.2 KiB |
@ -1,31 +0,0 @@ |
|||||
<openerp> |
|
||||
<data> |
|
||||
<record model="ir.ui.view" id="view_groups_form"> |
|
||||
<field name="inherit_id" ref="base.view_groups_form" /> |
|
||||
<field name="model">res.groups</field> |
|
||||
<field name="arch" type="xml"> |
|
||||
<data> |
|
||||
<field name="name" position="after"> |
|
||||
<field name="is_dynamic" /> |
|
||||
</field> |
|
||||
<field name="users" position="attributes"> |
|
||||
<attribute name="attrs">{'readonly': [('is_dynamic', '=', True)]}</attribute> |
|
||||
</field> |
|
||||
<field name="users" position="before"> |
|
||||
<group name="auth_dynamic_groups" attrs="{'invisible': [('is_dynamic', '=', False)]}"> |
|
||||
<field |
|
||||
name="dynamic_group_condition" |
|
||||
placeholder="Fill in your condition..." |
|
||||
attrs="{'required': [('is_dynamic', '=', True)]}" |
|
||||
colspan="4" nolabel="1" /> |
|
||||
<button |
|
||||
type="object" |
|
||||
name="action_evaluate" |
|
||||
string="Evaluate" /> |
|
||||
</group> |
|
||||
</field> |
|
||||
</data> |
|
||||
</field> |
|
||||
</record> |
|
||||
</data> |
|
||||
</openerp> |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue