misc: get first existing oldest form in mass action (#88849) #1334

Merged
fpeters merged 1 commits from wip/88849-oldest-lazy-form-no-error into main 2024-03-29 14:04:29 +01:00
1 changed files with 3 additions and 2 deletions

View File

@ -4513,11 +4513,10 @@ class MassActionAfterJob(AfterJob):
# action not found
return
if item_ids:
oldest_lazy_form = formdef.data_class().get(item_ids[0]).get_as_lazy()
self.total_count = len(item_ids)
self.store()
oldest_lazy_form = None
publisher = get_publisher()
for i, formdata_id in enumerate(item_ids):
# do not load all formdatas at once as they can be modified during the loop
@ -4525,6 +4524,8 @@ class MassActionAfterJob(AfterJob):
formdata = formdef.data_class().get(formdata_id, ignore_errors=True)
if not formdata:
continue
if oldest_lazy_form is None:
oldest_lazy_form = formdata.get_as_lazy()
publisher.reset_formdata_state()
publisher.substitutions.feed(user)
publisher.substitutions.feed(formdef)