forked from shopinvader/odoo-shopinvader
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] fixes a possible infinite loop when computing variants
- Loading branch information
Showing
1 changed file
with
20 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
# @author Sébastien BEAU <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from sys import exc_info | ||
|
||
from odoo import models | ||
|
||
|
||
|
@@ -29,6 +31,21 @@ def _get_binding_to_process(self, bindings, batch_size): | |
== bindings[idx].shopinvader_product_id | ||
): | ||
idx += 1 | ||
return processing | bindings[0:idx], bindings[idx:] | ||
else: | ||
return processing, bindings | ||
processing, bindings = processing | bindings[0:idx], bindings[idx:] | ||
if not bindings: | ||
# if there is no bindings that means that the job has not | ||
# been splitted. If we are in an exception we just re raise it | ||
# and the whole list of variants will not be computed. | ||
# Not doing so would result in an infinite loop unless we | ||
# force splitting to go down to the exact variant that raises | ||
# the error, but at the expense of possibly a lot of jobs created | ||
# raising errors. | ||
# Note that it can lead to variants not being recomputed which | ||
# should have been recomputed without error. | ||
|
||
# Note : from python 3.11 on use sys.exception() instead | ||
e = exc_info()[1] | ||
if e: | ||
raise e | ||
|
||
return processing, bindings |