2010-03-10 13:48:09 +00:00
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
##############################################################################
|
2010-03-17 08:56:10 +00:00
|
|
|
|
#
|
2010-03-10 13:48:09 +00:00
|
|
|
|
# OpenERP, Open Source Management Solution
|
|
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
|
|
|
#
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
2010-03-17 08:56:10 +00:00
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-03-10 13:48:09 +00:00
|
|
|
|
#
|
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
|
|
from osv import fields, osv
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
class audittrail_view_log(osv.osv_memory):
|
|
|
|
|
|
|
|
|
|
_name = "audittrail.view.log"
|
|
|
|
|
_description = "View Log"
|
2010-03-17 05:03:01 +00:00
|
|
|
|
_columns = {
|
|
|
|
|
'from':fields.datetime('Log From'),
|
|
|
|
|
'to':fields.datetime('Log To', required = True)
|
2010-03-10 13:48:09 +00:00
|
|
|
|
}
|
2010-03-17 05:03:01 +00:00
|
|
|
|
_defaults = {
|
|
|
|
|
'to': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
|
|
}
|
2010-03-10 13:48:09 +00:00
|
|
|
|
|
2010-03-17 05:03:01 +00:00
|
|
|
|
def log_open_window(self, cr, uid, ids, context=None):
|
2010-03-10 13:48:09 +00:00
|
|
|
|
"""
|
|
|
|
|
Open Log form from given date range..
|
|
|
|
|
@param cr: the current row, from the database cursor,
|
|
|
|
|
@param uid: the current user’s ID for security checks,
|
|
|
|
|
@param ids: List of audittrail view log’s IDs.
|
|
|
|
|
@return: Dictionary of audittrail log form on given date range.
|
|
|
|
|
"""
|
2010-03-17 05:03:01 +00:00
|
|
|
|
if not context:
|
|
|
|
|
context = {}
|
|
|
|
|
|
2010-03-10 13:48:09 +00:00
|
|
|
|
mod_obj = self.pool.get('ir.model.data')
|
|
|
|
|
act_obj = self.pool.get('ir.actions.act_window')
|
|
|
|
|
result = mod_obj._get_id(cr, uid, 'audittrail', 'action_audittrail_log_tree')
|
|
|
|
|
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
|
|
|
|
|
result = act_obj.read(cr, uid, [id])[0]
|
2010-03-17 05:03:01 +00:00
|
|
|
|
log_obj = self.pool.get(result['res_model'])
|
|
|
|
|
#log_id = log_obj.search(cr, uid, [])
|
|
|
|
|
#log_model = log_obj.read(cr, uid, log_id, ['object_id'])
|
|
|
|
|
#start Loop
|
|
|
|
|
for datas in self.read(cr, uid, ids):
|
|
|
|
|
if not datas.get('from', None):
|
|
|
|
|
if datas.get('to') <> time.strftime("%Y-%m-%d %H:%M:%S"):
|
|
|
|
|
result['domain'] = str([('timestamp', '<', datas.get('to'))])
|
2010-03-10 13:48:09 +00:00
|
|
|
|
else:
|
2010-03-17 05:03:01 +00:00
|
|
|
|
pass
|
2010-03-10 13:48:09 +00:00
|
|
|
|
else:
|
2010-03-17 05:03:01 +00:00
|
|
|
|
result['domain'] = str([('timestamp', '>', datas.get('from', None)), ('timestamp', '<', datas.get('to'))])
|
|
|
|
|
#End Loop
|
2010-03-10 13:48:09 +00:00
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
audittrail_view_log()
|