Add depends attributes to Columns.

It allow to specify a list of fields that are needed in the view for this one.
Add active field by default in each views.
This commit is contained in:
Cédric Krier
2009-01-09 18:42:00 +01:00
parent 4f40f3876a
commit aceccd0c74
2 changed files with 14 additions and 1 deletions
+2 -1
View File
@@ -54,7 +54,7 @@ class Column(object):
domain=None, context='', states=None, priority=0,
change_default=False, size=None, ondelete="SET NULL",
translate=False, select=0, on_change=None, on_change_with=None,
**args):
depends=None, **args):
self.states = states or {}
self.string = string
self.readonly = readonly
@@ -67,6 +67,7 @@ class Column(object):
self.translate = translate
self._domain = domain or []
self._context = context
self.depends = depends or []
if select not in (0, 1, 2):
raise Exception('Error', 'Select must be one of 0, 1, 2')
self.select = select
+12
View File
@@ -2184,6 +2184,18 @@ class ORM(object):
fields_def = self.__view_look_dom(cursor, user, tree_root, type,
fields_width=fields_width, context=context)
for field_name in fields_def.keys():
if field_name in self._columns:
field = self._columns[field_name]
else:
field = self._inherit_fields[field_name][2]
for depend in field.depends:
fields_def.setdefault(depend, {})
if ('active' in self._columns) or ('active' in self._inherit_fields):
fields_def.setdefault('active', {'select': "2"})
arch = etree.tostring(tree, encoding='utf-8', pretty_print=False)
fields2 = self.fields_get(cursor, user, fields_def.keys(), context)
for field in fields_def: