[IMP] do not delete res.log items after reading them
Just mark them as read bzr revid: xmo@openerp.com-20101012152602-0adn5ed1ztgch2xa
This commit is contained in:
@@ -33,20 +33,26 @@ class res_log(osv.osv_memory):
|
||||
'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'),
|
||||
'create_date': fields.datetime('Created Date', readonly=True),
|
||||
'read': field.boolean('Read status', help="If this log item has been read, get() should not send it to the client")
|
||||
}
|
||||
_defaults = {
|
||||
'user_id': lambda self,cr,uid,ctx: uid,
|
||||
'create_date': time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'context': lambda *args: "{}"
|
||||
'context': lambda *args: "{}",
|
||||
'read': False
|
||||
}
|
||||
_order='create_date 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)
|
||||
self.unlink(cr, uid, ids, context=context)
|
||||
return result
|
||||
def get(self, cr, uid, context=None):
|
||||
unread_log_ids = self.search(cr, uid, [('user_id','=',uid),
|
||||
('read', '=', False)],
|
||||
context=context)
|
||||
unread_logs = self.read(cr, uid, unread_log_ids,
|
||||
['name','res_model','res_id'],
|
||||
context=context)
|
||||
self.write(cr, uid, ids, {'read': True}, context=context)
|
||||
return unread_logs
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
|
||||
res = []
|
||||
|
||||
Reference in New Issue
Block a user