20 lines
707 B
Python
20 lines
707 B
Python
from apps.pum.models import PuOrderItem, PuPlan, PuPlanItem, PuOrder
|
|
|
|
class PumService:
|
|
|
|
def change_puplan_state_when_puorder_sumbit(puorder: PuOrder):
|
|
puplanIds = PuPlanItem.objects.filter(pu_order=puorder).values_list('pu_plan', flat=True)
|
|
for id in puplanIds:
|
|
puplan = PuPlan.objects.get(id=id)
|
|
state = puplan.state
|
|
if PuPlanItem.objects.filter(pu_plan=puplan).count() == PuPlan.objects.filter(pu_plan=puplan, pu_order__state__gte=PuOrder.PUORDER_SUBMITED).count():
|
|
state = PuPlan.PUPLAN_ORDERED
|
|
else:
|
|
state = PuPlan.PUPLAN_ORDERING
|
|
puplan.state = state
|
|
puplan.save()
|
|
|
|
|
|
|
|
|