from inventory.models import Lead, Car from django.contrib.auth.models import Permission from django.core.management.base import BaseCommand from django.contrib.contenttypes.models import ContentType from django_ledger.models import EstimateModel, BillModel, AccountModel, LedgerModel class Command(BaseCommand): def handle(self, *args, **kwargs): # Permission.objects.get_or_create( # name="Can view crm", # codename="can_view_crm", # content_type=ContentType.objects.get_for_model(Lead), # ) # Permission.objects.get_or_create( # name="Can reassign lead", # codename="can_reassign_lead", # content_type=ContentType.objects.get_for_model(Lead), # ) Permission.objects.get_or_create( name="Can view sales", codename="can_view_sales", content_type=ContentType.objects.get_for_model(EstimateModel), ) Permission.objects.get_or_create( name="Can view reports", codename="can_view_reports", content_type=ContentType.objects.get_for_model(LedgerModel), ) Permission.objects.get_or_create( name="Can view inventory", codename="can_view_inventory", content_type=ContentType.objects.get_for_model(Car), ) Permission.objects.get_or_create( name="Can approve bill", codename="can_approve_billmodel", content_type=ContentType.objects.get_for_model(BillModel), ) Permission.objects.get_or_create( name="Can view financials", codename="can_view_financials", content_type=ContentType.objects.get_for_model(AccountModel), ) Permission.objects.get_or_create( name="Can approve estimate", codename="can_approve_estimatemodel", content_type=ContentType.objects.get_for_model(EstimateModel), )