[FIX] Improve logging system
bzr revid: fp@tinyerp.com-20100519200214-rvl5gnb02a6utpau
This commit is contained in:
parent
bf025fedb6
commit
a527812316
|
@ -27,12 +27,14 @@ class res_log(osv.osv_memory):
|
|||
'name': fields.char('Message', size=128, help='The logging message.', required=True),
|
||||
'user_id': fields.many2one('res.users','User', required=True),
|
||||
'res_model': fields.char('Object', size=128),
|
||||
'res_id': fields.integer('Object ID')
|
||||
'res_id': fields.integer('Object ID'),
|
||||
'secondary': fields.boolean('Secondary Log', help='Do not display this log if it belongs to the same object the user is working on')
|
||||
}
|
||||
_defaults = {
|
||||
'user_id': lambda self,cr,uid,ctx: uid
|
||||
}
|
||||
_order='id desc'
|
||||
# TODO: do not return secondary log if same object than in the model (but unlink it)
|
||||
def get(self, cr, uid, context={}):
|
||||
ids = self.search(cr, uid, [('user_id','=',uid)], context=context)
|
||||
result = self.read(cr, uid, ids, ['name','res_model','res_id'], context=context)
|
||||
|
|
|
@ -398,13 +398,14 @@ class orm_template(object):
|
|||
_inherits = {}
|
||||
_table = None
|
||||
_invalids = set()
|
||||
_log_create = True
|
||||
_log_create = False
|
||||
|
||||
CONCURRENCY_CHECK_FIELD = '__last_update'
|
||||
def log(self, cr, uid, id, message, context=None):
|
||||
def log(self, cr, uid, id, message, secondary=False, context=None):
|
||||
return self.pool.get('res.log').create(cr, uid, {
|
||||
'name': message,
|
||||
'res_model': self._name,
|
||||
'secondary': secondary,
|
||||
'res_id': id},
|
||||
context=context
|
||||
)
|
||||
|
@ -1739,7 +1740,6 @@ class orm_memory(orm_template):
|
|||
_max_count = 200
|
||||
_max_hours = 1
|
||||
_check_time = 20
|
||||
_log_create = False
|
||||
|
||||
def __init__(self, cr):
|
||||
super(orm_memory, self).__init__(cr)
|
||||
|
@ -1845,7 +1845,7 @@ class orm_memory(orm_template):
|
|||
" '" + \
|
||||
self.name_get(cr, user, [id_new], context=context)[0][1] + \
|
||||
"' "+ _("created.")
|
||||
self.log(cr, user, id_new, message, context=context)
|
||||
self.log(cr, user, id_new, message, True, context=context)
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_create(user, self._name, id_new, cr)
|
||||
return id_new
|
||||
|
@ -2004,7 +2004,6 @@ class orm_memory(orm_template):
|
|||
class orm(orm_template):
|
||||
_sql_constraints = []
|
||||
_table = None
|
||||
_log_create = True
|
||||
_protected = ['read','write','create','default_get','perm_read','unlink','fields_get','fields_view_get','search','name_get','distinct_field_get','name_search','copy','import_data','search_count', 'exists']
|
||||
|
||||
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None):
|
||||
|
@ -3461,8 +3460,7 @@ class orm(orm_template):
|
|||
" '" + \
|
||||
self.name_get(cr, user, [id_new], context=context)[0][1] + \
|
||||
"' "+ _("created.")
|
||||
self.log(cr, user, id_new, message, context=context)
|
||||
|
||||
self.log(cr, user, id_new, message, True, context=context)
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_create(user, self._name, id_new, cr)
|
||||
return id_new
|
||||
|
|
Loading…
Reference in New Issue