mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-14 01:41:26 -06:00

* [MIG] Migration to version 10.0 * [FIX] Comments and CI errors * [FIX] ValueError: External ID not found in the system: base.menu_base_partner * [FIX] ValueError: Wrong value for ir.actions.act_window.target: 'inlineview' * [FIX] Based on @lasley comments * [FIX] External ID not found in the system: base.group_document_user
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
|
|
from odoo import exceptions, fields, models
|
|
from odoo.tools.translate import _
|
|
|
|
|
|
class DocumentPageShowDiff(models.TransientModel):
|
|
"""Display Difference for History."""
|
|
|
|
_name = 'wizard.document.page.history.show_diff'
|
|
|
|
def get_diff(self):
|
|
"""Return the Difference between two document."""
|
|
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(ids[1], ids[0])
|
|
else:
|
|
diff = history.getDiff(ids[0], ids[1])
|
|
elif len(ids) == 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 exceptions.Warning(
|
|
_("Select one or maximum two history revisions!")
|
|
)
|
|
return diff
|
|
|
|
diff = fields.Text(
|
|
'Diff',
|
|
readonly=True,
|
|
default=get_diff
|
|
)
|