[IMP] openupgrade_records: compare columns of many2many tables

pull/2196/head
mreficent 2021-03-23 18:10:00 +01:00 committed by Sylvain LE GAL
parent ba1bbeb82d
commit 1a8d67c991
2 changed files with 21 additions and 0 deletions

View File

@ -114,6 +114,8 @@ def fieldprint(old, new, field, text, reprs):
fullrepr = "{:<12} / {:<24} / {:<30}".format(old["module"], old["model"], fieldrepr)
if not text:
text = "{} is now '{}' ('{}')".format(field, new[field], old[field])
if field in ("column1", "column2"):
text += " [%s]" % old["table"]
if field == "relation":
text += " [nothing to do]"
reprs[module_map(old["module"])].append("{}: {}".format(fullrepr, text))
@ -161,6 +163,14 @@ def report_generic(new, old, attrs, reprs):
else:
text = "not related anymore"
fieldprint(old, new, "", text, reprs)
elif attr == "table":
if old[attr] != new[attr]:
fieldprint(old, new, attr, "", reprs)
if old[attr] and new[attr]:
if old["column1"] != new["column1"]:
fieldprint(old, new, "column1", "", reprs)
if old["column2"] != new["column2"]:
fieldprint(old, new, "column2", "", reprs)
elif old[attr] != new[attr]:
fieldprint(old, new, attr, "", reprs)

View File

@ -118,6 +118,17 @@ class UpgradeRecord(models.Model):
}
)
repre.update({x.name: x.value for x in record.attribute_ids})
if repre["table"]:
repre.update(
{
"column1": self.env[repre["model"]]
._fields[repre["field"]]
.column1,
"column2": self.env[repre["model"]]
._fields[repre["field"]]
.column2,
}
)
data.append(repre)
return data