changeset f71af880465b in modules/stock:5.8
details: https://hg.tryton.org/modules/stock?cmd=changeset&node=f71af880465b
description:
Do not modify iterated list to not miss product
issue10872
review372361002
(grafted from cba100c1c8ab41a4dec96048f21b554b0529b82e)
diffstat:
product.py | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diffs (25 lines):
diff -r d32e2e8c11e8 -r f71af880465b product.py
--- a/product.py Wed Sep 01 22:54:25 2021 +0200
+++ b/product.py Thu Oct 21 00:07:14 2021 +0200
@@ -862,8 +862,8 @@
revisions = []
costs = defaultdict(list)
if self.model.__name__ == 'product.product':
- products = records = list(self.records)
- for product in products:
+ records = list(self.records)
+ for product in list(records):
revision = self.get_revision(Revision)
revision.product = product
revision.template = product.template
@@ -876,8 +876,8 @@
costs[cost].append(product)
records.remove(product)
elif self.model.__name__ == 'product.template':
- templates = records = list(self.records)
- for template in templates:
+ records = list(self.records)
+ for template in list(records):
revision = self.get_revision(Revision)
revision.template = template
revisions.append(revision)