[IMP] tracked: models now have a _track attribute, telling the subtype to use for logging tracked fields. tracked attribute on columns become _track_visibility, telling if a field must always be logged or only when changed (to keep context value in logging message).
bzr revid: tde@openerp.com-20121217191059-g5jdm0yjee1gttta
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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 = {}
|
||||
|
||||
Reference in New Issue
Block a user