Skip to content

Commit

Permalink
Fix AttributeError on upgrade step 2654 (reindex_getDueDate) (#2638)
Browse files Browse the repository at this point in the history
* Uncatalog stale brains on upgrade

* Changelog

---------

Co-authored-by: Ramon Bartl <rb@ridingbytes.com>
  • Loading branch information
xispa and ramonski authored Nov 4, 2024
1 parent bf1acf6 commit ff5ee60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog
------------------

- #2639 Fix sampletype-related indexes for AnalysisSpec type are not indexed
- #2638 Fix AttributeError on upgrade step 2654 (reindex_getDueDate)
- #2569 Fix samples are indicated as late when Turnaround Time is zero
- #2636 Fix JS Error in WS Template edit form
- #2635 Remove reindexing of Analyses and Analysis Services on Category change
Expand Down
9 changes: 8 additions & 1 deletion src/senaite/core/upgrade/v02_06_000.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
from senaite.core.upgrade.utils import del_metadata
from senaite.core.upgrade.utils import delete_object
from senaite.core.upgrade.utils import permanently_allow_type_for
from senaite.core.upgrade.utils import uncatalog_brain
from senaite.core.upgrade.utils import uncatalog_object
from senaite.core.upgrade.utils import UpgradeUtils
from senaite.core.workflow import ANALYSIS_WORKFLOW
Expand Down Expand Up @@ -2079,7 +2080,13 @@ def reindex_getDueDate(tool):
total = len(brains)
sample_uids = set()
for num, brain in enumerate(brains):
obj = api.get_object(brain)
try:
obj = api.get_object(brain, default=None)
except AttributeError:
obj = None
if obj is None:
uncatalog_brain(brain)
continue
if not IRequestAnalysis.providedBy(obj):
continue
if num and num % 100 == 0:
Expand Down

0 comments on commit ff5ee60

Please sign in to comment.