fix customer and well form
This commit is contained in:
		
							parent
							
								
									3b61931bf0
								
							
						
					
					
						commit
						4df61c8a01
					
				
					 3 changed files with 12 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -3,6 +3,7 @@ from django.contrib.auth import get_user_model
 | 
			
		|||
from django.core.exceptions import ValidationError
 | 
			
		||||
from .models import Well, WaterMeterManufacturer
 | 
			
		||||
from locations.models import Affairs, County, Broker
 | 
			
		||||
from common.consts import UserRoles
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class WaterMeterManufacturerForm(forms.ModelForm):
 | 
			
		||||
| 
						 | 
				
			
			@ -118,8 +119,10 @@ class WellForm(forms.ModelForm):
 | 
			
		|||
    def __init__(self, *args, **kwargs):
 | 
			
		||||
        super().__init__(*args, **kwargs)
 | 
			
		||||
        
 | 
			
		||||
        # تنظیم querysetها
 | 
			
		||||
        self.fields['representative'].queryset = get_user_model().objects.all()
 | 
			
		||||
        # تنظیم querysetها - فقط کاربرانی که نقش مشترک دارند
 | 
			
		||||
        self.fields['representative'].queryset = get_user_model().objects.filter(
 | 
			
		||||
            profile__roles__slug=UserRoles.CUSTOMER.value
 | 
			
		||||
        )
 | 
			
		||||
        self.fields['water_meter_manufacturer'].queryset = WaterMeterManufacturer.objects.all()
 | 
			
		||||
        
 | 
			
		||||
        # اضافه کردن گزینه خالی
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue