summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMantavya Gajjar <mga@tinyerp.com>2008-03-26 08:05:50 +0000
committerMantavya Gajjar <mga@tinyerp.com>2008-03-26 08:05:50 +0000
commit4ee1ffc4d0c70cc081b54cd2e32c00323c8a0e2e (patch)
treefad8f6357e38e436fd4fc6f4b09047166e25c436
parent7cc65bad3e3252761f9bb52eac3171151904a1cc (diff)
Small change
01:44:08 IST) Fabien (fp): Some notes: I think that when you put groups on the view, it's to hide the field, not to put it as readonly. bzr revid: mga@tinyerp.com-78252a0a6619393ed5fabb79219689dc32172f4a
-rw-r--r--bin/osv/orm.py50
1 files changed, 30 insertions, 20 deletions
diff --git a/bin/osv/orm.py b/bin/osv/orm.py
index 3c5fb2f6dde..ff447e817f6 100644
--- a/bin/osv/orm.py
+++ b/bin/osv/orm.py
@@ -1469,32 +1469,38 @@ class orm(object):
attrs = {'views': views}
fields[node.getAttribute('name')] = attrs
- if node.hasAttribute('groups'):
- groups = None
- group_str = node.getAttribute('groups')
- if ',' in group_str:
- groups = group_str.split(',');
- readonly = False
- access_pool = self.pool.get('ir.model.access')
- for group in groups:
- readonly = readonly and access_pool.check_groups(cr, user, group)
-
- if readonly:
- fields[node.getAttribute('name')] = {'readonly':True}
- else:
- fields[node.getAttribute('name')] = {'readonly':False}
-
- else:
- if not self.pool.get('ir.model.access').check_groups(cr, user, group_str):
- fields[node.getAttribute('name')] = {'readonly':True}
- else:
- fields[node.getAttribute('name')] = {'readonly':False}
+
elif node.nodeType==node.ELEMENT_NODE and node.localName in ('form','tree'):
result = self.view_header_get(cr, user, False, node.localName, context)
if result:
node.setAttribute('string', result.decode('utf-8'))
+ if node.nodeType==node.ELEMENT_NODE and node.hasAttribute('groups'):
+ groups = None
+ group_str = node.getAttribute('groups')
+ if ',' in group_str:
+ groups = group_str.split(',');
+ readonly = False
+ access_pool = self.pool.get('ir.model.access')
+ for group in groups:
+ readonly = readonly and access_pool.check_groups(cr, user, group)
+
+ if readonly:
+ parent = node.parentNode
+ parent.removeChild(node)
+ #fields[node.getAttribute('name')] = {'readonly':True}
+ #node.re
+ else:
+ fields[node.getAttribute('name')] = {'readonly':False}
+ else:
+ if not self.pool.get('ir.model.access').check_groups(cr, user, group_str):
+ #fields[node.getAttribute('name')] = {'readonly':True}
+ parent = node.parentNode
+ parent.removeChild(node)
+ else:
+ fields[node.getAttribute('name')] = {'readonly':False}
+
if node.nodeType == node.ELEMENT_NODE:
# translate view
if ('lang' in context) and not result:
@@ -1563,6 +1569,7 @@ class orm(object):
arch = node.toxml(encoding="utf-8").replace('\t', '')
fields = self.fields_get(cr, user, fields_def.keys(), context)
+
for field in fields_def:
fields[field].update(fields_def[field])
return arch, fields
@@ -1751,6 +1758,7 @@ class orm(object):
resaction = ir_values_obj.get(cr, user, 'action',
'client_action_multi', [(self._name, False)], False,
context)
+
resrelate = ir_values_obj.get(cr, user, 'action',
'client_action_relate', [(self._name, False)], False,
context)
@@ -1759,8 +1767,10 @@ class orm(object):
resaction = filter(lambda x: not x.get('multi',False), resaction)
resprint = filter(lambda x: not x.get('multi',False), resprint)
resrelate = map(lambda x:x[2], resrelate)
+
for x in resprint+resaction+resrelate:
x['string'] = x['name']
+
result['toolbar'] = {
'print': resprint,
'action': resaction,