-
This view has no previous version.
-
This view is not coming from a file.
+
+ This view has no previous version.
+ This view is not coming from a file.
+ You need two views to compare.
@@ -125,8 +131,8 @@
diff --git a/odoo/tools/misc.py b/odoo/tools/misc.py
index 534493afa95..b19e3b44923 100644
--- a/odoo/tools/misc.py
+++ b/odoo/tools/misc.py
@@ -29,6 +29,7 @@ import unicodedata
import werkzeug.utils
import zipfile
from collections import defaultdict, Iterable, Mapping, MutableMapping, MutableSet, OrderedDict
+from difflib import HtmlDiff
from itertools import islice, groupby as itergroupby, repeat
from lxml import etree
@@ -1470,3 +1471,48 @@ class DotDict(dict):
def __getattr__(self, attrib):
val = self.get(attrib)
return DotDict(val) if type(val) is dict else val
+
+
+def get_diff(data_from, data_to, custom_style=False):
+ """
+ Return, in an HTML table, the diff between two texts.
+
+ :param tuple data_from: tuple(text, name), name will be used as table header
+ :param tuple data_to: tuple(text, name), name will be used as table header
+ :param tuple custom_style: string, style css including
+ '''
+ return html_diff
+
+ diff = HtmlDiff(tabsize=2).make_table(
+ data_from[0].splitlines(),
+ data_to[0].splitlines(),
+ data_from[1],
+ data_to[1],
+ context=True, # Show only diff lines, not all the code
+ numlines=3,
+ )
+ return handle_style(diff, custom_style)