[FIX] runbot: fix bundle without batch display

In some case, when creating a bundle from the backend, it is possible
that the bundle has no batch at all, making _get_global_result() fail.
This commit is contained in:
Xavier-Do 2024-12-05 08:07:53 +01:00 committed by xdo
parent 58f0f8108a
commit 4f3838b7e9

View File

@ -59,6 +59,8 @@ class Batch(models.Model):
def _get_global_result(self): def _get_global_result(self):
"""Returns the worst result from the related builds and logs""" """Returns the worst result from the related builds and logs"""
if not self:
return 'ok'
self.ensure_one() self.ensure_one()
batch_result = 'warn' if any(log.level != 'INFO' for log in self.log_ids) else 'ok' batch_result = 'warn' if any(log.level != 'INFO' for log in self.log_ids) else 'ok'
if self.state == 'skipped': if self.state == 'skipped':