Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions upgrade_analysis/models/upgrade_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,23 @@ def _get_xml_diff(
"name"
}:
# if previous version has set a field but current version
# doesn't, set whatever the NULL value of the field is
# (usually None)
# doesn't, reset it to the value a fresh install would give
# it: the field's default. Only fall back to the field's
# falsy value when there is no default. Using falsy_value
# unconditionally is wrong for fields whose default is truthy
# (e.g. ir.rule.perm_* or active) and can even produce
# records that violate model constraints.
model = self.env[local_record.attrib["model"]]
field = model._fields[attribs["name"]]
eval_constant = ast.unparse(ast.Constant(field.falsy_value))
reset_value = model.default_get([field.name]).get(
field.name, field.falsy_value
)
try:
eval_constant = ast.unparse(ast.Constant(reset_value))
except ValueError:
# non-scalar default (e.g. x2many command list):
# keep the previous behaviour
eval_constant = ast.unparse(ast.Constant(field.falsy_value))
if eval_constant != "''":
attribs["eval"] = eval_constant
element.append(etree.Element(record_remote_dict[key].tag, attribs))
Expand Down
Loading