Skip to content

Commit

Permalink
[FIX] util/records: do not perform callback if xmlid is gone
Browse files Browse the repository at this point in the history
Before acceff5 we returned early if the xmlid passed to `if_unchanged`
was missing. After that commit was merged we always execute the
`callback`. This is problematic when the callback is
`update_record_from_xml`. It will create records even if they are in
`forcecreate=0`.

closes #203

Signed-off-by: Christophe Simonis (chs) <chs@odoo.com>
  • Loading branch information
aj-fuentes committed Jan 30, 2025
1 parent 0ad717f commit 946deba
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/util/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,12 @@ def is_changed(cr, xmlid, interval="1 minute"):
* Have been updated in an upgrade preceding the current one
* Have not been updated in the current upgrade
If the `xmlid` doesn't exist in the DB this function returns ``None``.
:param str xmlid: `xmlid` of the record to check
:param str interval: SQL interval, a record is considered as changed if
`write_date > create_date + interval`
:rtype: bool
:rtype: bool or None
"""
assert "." in xmlid
module, _, name = xmlid.partition(".")
Expand Down Expand Up @@ -620,7 +622,10 @@ def if_unchanged(cr, xmlid, callback, interval="1 minute", **kwargs):
:param str interval: interval after `create_date` on which a record is considered as
_changed_, see :func:`~odoo.upgrade.util.misc.is_changed`
"""
if not is_changed(cr, xmlid, interval=interval):
changed = is_changed(cr, xmlid, interval=interval)
if changed is None:
return
if changed is False:
callback(cr, xmlid, **kwargs)
else:
force_noupdate(cr, xmlid, noupdate=True)
Expand Down

0 comments on commit 946deba

Please sign in to comment.