21 lines
		
	
	
		
			777 B
		
	
	
	
		
			Python
		
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			777 B
		
	
	
	
		
			Python
		
	
	
	
| from django.db.models.signals import post_save
 | |
| from django.dispatch import receiver
 | |
| from apps.pm.models import SubProductionPlan, SubProductionProgress
 | |
| 
 | |
| @receiver(post_save, sender=SubProductionProgress)
 | |
| def update_subplan_main(sender, instance, created, **kwargs):
 | |
|     """
 | |
|     根据生产进度统计表更新子计划进度表相关字段
 | |
|     """
 | |
|     if instance.is_main:
 | |
|         subplan = instance.subproduction_plan
 | |
|         if created:
 | |
|             subplan.main_product = instance.material
 | |
|             subplan.main_count = instance.count
 | |
|         subplan.main_count_real = instance.count_real
 | |
|         if instance.count_real>= instance.count and instance.count_real != 0:
 | |
|             subplan.state = SubProductionPlan.SUBPLAN_STATE_DONE
 | |
|         subplan.save() 
 | |
| 
 | |
|             
 |