mirror of
https://github.com/OCA/knowledge.git
synced 2025-12-19 03:42:19 -06:00
use new API
This commit is contained in:
committed by
FernandoRomera
parent
742c9c90e1
commit
cd11965527
@@ -18,46 +18,44 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools.translate import _
|
||||
from openerp import models, fields, _
|
||||
from openerp import exceptions
|
||||
|
||||
|
||||
class showdiff(osv.osv_memory):
|
||||
""" Disp[ay Difference for History """
|
||||
class showdiff(models.TransientModel):
|
||||
""" Display Difference for History """
|
||||
|
||||
_name = 'wizard.document.page.history.show_diff'
|
||||
|
||||
def get_diff(self, cr, uid, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
history = self.pool.get('document.page.history')
|
||||
ids = context.get('active_ids', [])
|
||||
def get_diff(self):
|
||||
history = self.env["document.page.history"]
|
||||
ids = self.env.context.get('active_ids', [])
|
||||
|
||||
diff = ""
|
||||
if len(ids) == 2:
|
||||
if ids[0] > ids[1]:
|
||||
diff = history.getDiff(cr, uid, ids[1], ids[0])
|
||||
diff = history.getDiff(ids[1], ids[0])
|
||||
else:
|
||||
diff = history.getDiff(cr, uid, ids[0], ids[1])
|
||||
|
||||
diff = history.getDiff(ids[0], ids[1])
|
||||
elif len(ids) == 1:
|
||||
old = history.browse(cr, uid, ids[0])
|
||||
nids = history.search(cr, uid, [('page_id', '=', old.page_id.id)])
|
||||
nids.sort()
|
||||
diff = history.getDiff(cr, uid, ids[0], nids[-1])
|
||||
old = history.browse(ids[0])
|
||||
nids = history.search(
|
||||
[('page_id', '=', old.page_id.id)],
|
||||
order='id DESC',
|
||||
limit=1
|
||||
)
|
||||
diff = history.getDiff(ids[0], nids.id)
|
||||
else:
|
||||
raise osv.except_osv(_('Warning!'), _('You need to select minimum \
|
||||
one or maximum two history \
|
||||
revisions!'))
|
||||
raise exceptions.Warning(
|
||||
_("You need to select minimum one or maximum "
|
||||
"two history revisions!")
|
||||
)
|
||||
return diff
|
||||
|
||||
_columns = {
|
||||
'diff': fields.text('Diff', readonly=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'diff': get_diff
|
||||
}
|
||||
diff = fields.Text(
|
||||
'Diff',
|
||||
readonly=True,
|
||||
default=get_diff
|
||||
)
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
Reference in New Issue
Block a user