[IMP][10.0][document_page] Change Requests and workflow improvements on documents (#155)

This commit is contained in:
Iván Todorovich
2018-04-13 11:36:33 -03:00
committed by FernandoRomera
parent b862c87e8c
commit 47320de3a2
21 changed files with 518 additions and 364 deletions

View File

@@ -2,7 +2,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 import fields, models
from odoo.exceptions import UserError
from odoo.tools.translate import _
@@ -11,33 +12,24 @@ class DocumentPageShowDiff(models.TransientModel):
_name = 'wizard.document.page.history.show_diff'
def get_diff(self):
def _get_diff(self):
"""Return the Difference between two document."""
history = self.env["document.page.history"]
ids = self.env.context.get('active_ids', [])
diff = ""
diff = False
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)
diff = history.browse(ids[0]).diff
else:
raise exceptions.Warning(
_("Select one or maximum two history revisions!")
)
raise UserError(
_("Select one or maximum two history revisions!"))
return diff
diff = fields.Text(
'Diff',
readonly=True,
default=get_diff
default=_get_diff,
)