2009-10-13 05:58:37 +00:00
|
|
|
|
# -*- coding: utf-8 -*-
|
2008-11-24 07:52:15 +00:00
|
|
|
|
##############################################################################
|
2010-03-15 13:40:23 +00:00
|
|
|
|
#
|
2009-10-14 11:15:34 +00:00
|
|
|
|
# OpenERP, Open Source Management Solution
|
2010-01-12 09:18:39 +00:00
|
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
2008-11-24 07:52:15 +00:00
|
|
|
|
#
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2009-10-14 11:15:34 +00:00
|
|
|
|
# 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.
|
2008-11-24 07:52:15 +00:00
|
|
|
|
#
|
|
|
|
|
# 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
|
2009-10-14 11:15:34 +00:00
|
|
|
|
# GNU Affero General Public License for more details.
|
2008-11-24 07:52:15 +00:00
|
|
|
|
#
|
2009-10-14 11:15:34 +00:00
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
2010-03-15 13:40:23 +00:00
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-11-24 07:52:15 +00:00
|
|
|
|
#
|
|
|
|
|
##############################################################################
|
|
|
|
|
|
2010-03-17 09:27:12 +00:00
|
|
|
|
from osv import fields, osv
|
|
|
|
|
from tools.translate import _
|
2010-07-12 06:39:51 +00:00
|
|
|
|
import base64
|
2008-11-24 07:52:15 +00:00
|
|
|
|
|
|
|
|
|
class showdiff(osv.osv_memory):
|
2010-03-17 08:36:08 +00:00
|
|
|
|
""" Disp[ay Difference for History """
|
|
|
|
|
|
2012-08-03 15:46:41 +00:00
|
|
|
|
_name = 'wizard.document.page.history.show_diff'
|
2010-03-15 13:40:23 +00:00
|
|
|
|
|
2010-04-12 12:41:47 +00:00
|
|
|
|
def get_diff(self, cr, uid, context=None):
|
2010-03-17 08:36:08 +00:00
|
|
|
|
|
|
|
|
|
""" @param cr: the current row, from the database cursor,
|
|
|
|
|
@param uid: the current user’s ID for security checks,
|
|
|
|
|
"""
|
2010-11-23 07:05:05 +00:00
|
|
|
|
if context is None:
|
2010-11-22 10:37:53 +00:00
|
|
|
|
context = {}
|
2012-08-03 15:46:41 +00:00
|
|
|
|
history = self.pool.get('document.page.history')
|
2010-09-01 11:58:23 +00:00
|
|
|
|
ids = context.get('active_ids', [])
|
2010-07-12 06:39:51 +00:00
|
|
|
|
|
2008-11-24 10:14:28 +00:00
|
|
|
|
diff = ""
|
|
|
|
|
if len(ids) == 2:
|
|
|
|
|
if ids[0] > ids[1]:
|
2010-07-12 06:39:51 +00:00
|
|
|
|
diff = base64.encodestring(history.getDiff(cr, uid, ids[1], ids[0]))
|
2008-11-24 10:14:28 +00:00
|
|
|
|
else:
|
2010-07-12 06:39:51 +00:00
|
|
|
|
diff = base64.encodestring(history.getDiff(cr, uid, ids[0], ids[1]))
|
2008-11-24 10:14:28 +00:00
|
|
|
|
|
|
|
|
|
elif len(ids) == 1:
|
|
|
|
|
old = history.browse(cr, uid, ids[0])
|
2012-08-03 15:46:41 +00:00
|
|
|
|
nids = history.search(cr, uid, [('document_id', '=', old.document_id.id)])
|
2008-11-24 10:14:28 +00:00
|
|
|
|
nids.sort()
|
2010-07-12 06:39:51 +00:00
|
|
|
|
diff = base64.encodestring(history.getDiff(cr, uid, ids[0], nids[-1]))
|
2008-11-26 09:04:41 +00:00
|
|
|
|
else:
|
2012-08-07 11:34:14 +00:00
|
|
|
|
raise osv.except_osv(_('Warning!'), _('You need to select minimum one or maximum two history revisions!'))
|
2010-04-12 12:41:47 +00:00
|
|
|
|
|
2010-07-12 06:39:51 +00:00
|
|
|
|
|
2008-11-24 10:14:28 +00:00
|
|
|
|
return diff
|
2008-11-24 07:52:15 +00:00
|
|
|
|
|
|
|
|
|
_columns = {
|
2010-07-12 06:39:51 +00:00
|
|
|
|
'file_path':fields.binary('Diff', readonly=True),
|
2008-11-24 07:52:15 +00:00
|
|
|
|
}
|
2010-03-17 08:36:08 +00:00
|
|
|
|
|
2008-11-24 07:52:15 +00:00
|
|
|
|
_defaults = {
|
2010-07-12 06:39:51 +00:00
|
|
|
|
'file_path': get_diff
|
2008-11-24 07:52:15 +00:00
|
|
|
|
}
|
2010-03-17 08:36:08 +00:00
|
|
|
|
|
2009-03-06 22:18:24 +00:00
|
|
|
|
showdiff()
|
2010-03-17 08:36:08 +00:00
|
|
|
|
|
2009-03-06 22:18:24 +00:00
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|