[IMP] tracked: models now have a _track attribute, telling the subtype to use for...
authorThibault Delavallée <tde@openerp.com>
Mon, 17 Dec 2012 19:10:59 +0000 (20:10 +0100)
committerThibault Delavallée <tde@openerp.com>
Mon, 17 Dec 2012 19:10:59 +0000 (20:10 +0100)
bzr revid: tde@openerp.com-20121217191059-g5jdm0yjee1gttta

openerp/osv/fields.py
openerp/osv/orm.py

index 95b0ef6..b7dff94 100644 (file)
@@ -80,11 +80,12 @@ class _column(object):
     _symbol_f = _symbol_set
     _symbol_set = (_symbol_c, _symbol_f)
     _symbol_get = None
-
     # used to hide a certain field type in the list of field types
     _deprecated = False
+    # used for automatic logging system if mail installed (should be 'on_change' or 'always')
+    _track_visibility = False
 
-    def __init__(self, string='unknown', required=False, readonly=False, domain=None, context=None, states=None, priority=0, change_default=False, size=None, ondelete=None, translate=False, select=False, manual=False, tracked=False, **args):
+    def __init__(self, string='unknown', required=False, readonly=False, domain=None, context=None, states=None, priority=0, change_default=False, size=None, ondelete=None, translate=False, select=False, manual=False, track_visibility=False, **args):
         """
 
         The 'manual' keyword argument specifies if the field is a custom one.
@@ -103,7 +104,7 @@ class _column(object):
         self.help = args.get('help', '')
         self.priority = priority
         self.change_default = change_default
-        self.ondelete = ondelete.lower() if ondelete else None # defaults to 'set null' in ORM
+        self.ondelete = ondelete.lower() if ondelete else None  # defaults to 'set null' in ORM
         self.translate = translate
         self._domain = domain
         self._context = context
@@ -113,14 +114,14 @@ class _column(object):
         self.select = select
         self.manual = manual
         self.selectable = True
-        self.tracked = tracked  # Automatic logging system if mail installed
+        self._track_visibility = track_visibility
         self.group_operator = args.get('group_operator', False)
         self.groups = False  # CSV list of ext IDs of groups that can access this field
-        self.deprecated = False # Optional deprecation warning
+        self.deprecated = False  # Optional deprecation warning
         for a in args:
             if args[a]:
                 setattr(self, a, args[a])
+
     def restart(self):
         pass
 
index eb5b9f2..f5e46f7 100644 (file)
@@ -677,6 +677,23 @@ class BaseModel(object):
     _description = None
     _needaction = False
 
+    # Automatic logging system if mail installed
+    # _track = {
+    #   'field': {
+    #       'module.subtype_xml': lambda self, cr, uid, obj, context=None: obj.state == done,
+    #       'module.subtype_xml2': lambda self, cr, uid, obj, context=None: obj.state != done,
+    #   },
+    #   'field2': {
+    #       ...
+    #   },
+    # }
+    # where
+    #   :param string field: field name
+    #   :param module.subtype_xml: xml_id of a mail.message.subtype (i.e. mail.mt_comment)
+    #   :param obj: is a browse_record
+    #   :param function lambda: returns whether the tracking should record using this subtype
+    _track = {}
+
     # dict of {field:method}, with method returning the (name_get of records, {id: fold})
     # to include in the _read_group, if grouped on this field
     _group_by_full = {}