mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
mrp_sale_info: add measure to avoide infinite recursion error
This commit is contained in:
@@ -6,11 +6,20 @@ from odoo import models
|
||||
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"]
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user