diff --git a/addons/hr_work_entry/models/hr_work_entry.py b/addons/hr_work_entry/models/hr_work_entry.py index 4484bb443cc..10f737315eb 100644 --- a/addons/hr_work_entry/models/hr_work_entry.py +++ b/addons/hr_work_entry/models/hr_work_entry.py @@ -3,6 +3,7 @@ from contextlib import contextmanager from dateutil.relativedelta import relativedelta +from psycopg2 import OperationalError from odoo import api, fields, models @@ -169,6 +170,11 @@ class HrWorkEntry(models.Model): ]) work_entries._reset_conflicting_state() yield + except OperationalError: + # the cursor is dead, do not attempt to use it or we will shadow the root exception + # with a "psycopg2.InternalError: current transaction is aborted, ..." + skip = True + raise finally: if not skip and start and stop: # New work entries are handled in the create method,