Browse Source

[FIX] coding style

pull/112/head
Holger Brunn 10 years ago
parent
commit
c14061c6ad
  1. 2
      auth_dynamic_groups/__init__.py
  2. 16
      auth_dynamic_groups/__openerp__.py
  3. 4
      auth_dynamic_groups/model/__init__.py
  4. 7
      auth_dynamic_groups/model/res_groups.py
  5. 9
      auth_dynamic_groups/model/res_users.py

2
auth_dynamic_groups/__init__.py

@ -18,4 +18,4 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
import model
from . import model

16
auth_dynamic_groups/__openerp__.py

@ -19,9 +19,9 @@
# #
############################################################################## ##############################################################################
{ {
"name" : "Dynamic groups",
"version" : "1.0",
"author" : "Therp BV",
"name": "Dynamic groups",
"version": "1.0",
"author": "Therp BV",
"complexity": "normal", "complexity": "normal",
"description": """ "description": """
Description Description
@ -40,16 +40,16 @@ 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 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. members. The condition will be checked now for every user who logs in.
""", """,
"category" : "Tools",
"depends" : [
"category": "Tools",
"depends": [
'base', 'base',
], ],
"data" : [
"data": [
'view/res_groups.xml', 'view/res_groups.xml',
], ],
"auto_install": False, "auto_install": False,
"installable": True, "installable": True,
"external_dependencies" : {
'python' : [],
"external_dependencies": {
'python': [],
}, },
} }

4
auth_dynamic_groups/model/__init__.py

@ -18,5 +18,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
import res_users
import res_groups
from . import res_users
from . import res_groups

7
auth_dynamic_groups/model/res_groups.py

@ -31,10 +31,9 @@ class res_groups(Model):
_columns = { _columns = {
'is_dynamic': fields.boolean('Dynamic'), 'is_dynamic': fields.boolean('Dynamic'),
'dynamic_group_condition': fields.text( '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''')
'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')
} }
def eval_dynamic_group_condition(self, cr, uid, ids, context=None): def eval_dynamic_group_condition(self, cr, uid, ids, context=None):

9
auth_dynamic_groups/model/res_users.py

@ -18,11 +18,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
import logging
from openerp.osv.orm import Model from openerp.osv.orm import Model
from openerp.osv import fields
from openerp import pooler, SUPERUSER_ID from openerp import pooler, SUPERUSER_ID
class res_users(Model): class res_users(Model):
_inherit = 'res.users' _inherit = 'res.users'
@ -41,13 +40,15 @@ class res_users(Model):
groups_obj = pool.get('res.groups') groups_obj = pool.get('res.groups')
user.write( user.write(
{ {
'groups_id': [(4, dynamic_group.id)
'groups_id': [
(4, dynamic_group.id)
if dynamic_group.eval_dynamic_group_condition() if dynamic_group.eval_dynamic_group_condition()
else (3, dynamic_group.id) else (3, dynamic_group.id)
for dynamic_group in groups_obj.browse( for dynamic_group in groups_obj.browse(
cr, uid, cr, uid,
groups_obj.search(cr, uid, groups_obj.search(cr, uid,
[('is_dynamic', '=', True)]))]
[('is_dynamic', '=', True)]))
],
}) })
cr.commit() cr.commit()
cr.close() cr.close()
Loading…
Cancel
Save