1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Affero General Public License as
9
# published by the Free Software Foundation, either version 3 of the
10
# License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Affero General Public License for more details.
17
# You should have received a copy of the GNU Affero General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
##############################################################################
22
from osv import fields, osv
25
class audittrail_view_log(osv.osv_memory):
27
_name = "audittrail.view.log"
28
_description = "View Log"
30
'from':fields.datetime('Log From'),
31
'to':fields.datetime('Log To', required = True)
34
'to': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
37
def log_open_window(self, cr, uid, ids, context=None):
39
Open Log form from given date range..
40
@param cr: the current row, from the database cursor,
41
@param uid: the current user’s ID for security checks,
42
@param ids: List of audittrail view log’s IDs.
43
@return: Dictionary of audittrail log form on given date range.
46
mod_obj = self.pool.get('ir.model.data')
47
act_obj = self.pool.get('ir.actions.act_window')
48
result = mod_obj._get_id(cr, uid, 'audittrail', 'action_audittrail_log_tree')
49
id = mod_obj.read(cr, uid, [result], ['res_id'], context=context)[0]['res_id']
50
result = act_obj.read(cr, uid, [id], context=context)[0]
53
for datas in self.read(cr, uid, ids, context=context):
54
if not datas.get('from', None):
55
if datas.get('to') <> time.strftime("%Y-%m-%d %H:%M:%S"):
56
result['domain'] = str([('timestamp', '<', datas.get('to'))])
60
result['domain'] = str([('timestamp', '>', datas.get('from', None)), ('timestamp', '<', datas.get('to'))])