Commit cb0da24f authored by Łukasz Nowak's avatar Łukasz Nowak

Stop generation just bit after current moment.

Generate movement for next period and later rely on re expanding.
parent 446e2dae
No related merge requests found
...@@ -39,6 +39,7 @@ from Products.ERP5.mixin.rule import MovementGeneratorMixin ...@@ -39,6 +39,7 @@ from Products.ERP5.mixin.rule import MovementGeneratorMixin
from Products.ERP5.mixin.periodicity import PeriodicityMixin from Products.ERP5.mixin.periodicity import PeriodicityMixin
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
from DateTime import DateTime
from zLOG import LOG from zLOG import LOG
...@@ -291,6 +292,7 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin, Periodici ...@@ -291,6 +292,7 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin, Periodici
price_currency = movement.getPriceCurrency() price_currency = movement.getPriceCurrency()
specialise = movement.getSpecialise() specialise = movement.getSpecialise()
now = DateTime()
current_date = start_date current_date = start_date
id_index = 0 id_index = 0
while current_date < stop_date: while current_date < stop_date:
...@@ -313,9 +315,11 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin, Periodici ...@@ -313,9 +315,11 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin, Periodici
specialise=specialise, specialise=specialise,
) )
result.append(generated_movement) result.append(generated_movement)
if current_date > now:
# generate only one movement in advance from today
break
current_date = next_date current_date = next_date
id_index += 1 id_index += 1
break
return result return result
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment