From 0675a6a8c2d69dd1f98ec522884babe672b93832 Mon Sep 17 00:00:00 2001 From: Edoardo Piroli Date: Tue, 18 Jun 2024 15:03:01 +0200 Subject: [PATCH] [FIX] util/records: fix `delete_unused` DOCSTRING `delete_unused`, in spite of its name, deletes records even if they are used, provided they are not part of a foreign key with `restrict` or `set` ondelete clause (iow: allowing for cascading foreign keys). --- src/util/records.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/util/records.py b/src/util/records.py index 24d3c0b1..6b259e49 100644 --- a/src/util/records.py +++ b/src/util/records.py @@ -1098,10 +1098,13 @@ def add_ref(ref): def delete_unused(cr, *xmlids, **kwargs): """ - Remove unused records. + Remove unrestricted records. - This function will remove records pointed by `xmlids` only if they are not referenced - from any table. + This function will remove records, pointed by `xmlids`, only if they are NOT referenced + from any table with `restrict` or `set` ondelete clauses. + + .. warning:: + Indirect references are not checked and can cause the util to fail. .. note:: The records that cannot be removed are set as `noupdate=True`.