Skip to content

Commit

Permalink
mrp_sale_info: add measure to avoide infinite recursion error
Browse files Browse the repository at this point in the history
  • Loading branch information
JuMiSanAr committed Aug 22, 2024
1 parent ced236f commit ee8a755
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions mrp_sale_info/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@
class StockMove(models.Model):
_inherit = "stock.move"

def _get_orig_created_production_ids(self):
def _get_orig_created_production_ids(self, already_scanned_ids=None):
self.ensure_one()
if self.created_production_id:
return self.created_production_id
if not already_scanned_ids:
# 'already_scanned_ids' is used to avoid infinite loop errors,
# we only call this method recursively for moves that haven't been handled yet.
already_scanned_ids = []
mrp_production_ids = set()
for move in self.move_orig_ids:
mrp_production_ids.update(move._get_orig_created_production_ids().ids)
if move.id in already_scanned_ids:
return self.env["mrp.production"]

Check warning on line 20 in mrp_sale_info/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

mrp_sale_info/models/stock_move.py#L20

Added line #L20 was not covered by tests
already_scanned_ids.append(move.id)
mrp_production_ids.update(
move._get_orig_created_production_ids(already_scanned_ids).ids
)
return self.env["mrp.production"].browse(mrp_production_ids)

0 comments on commit ee8a755

Please sign in to comment.