I \'ve already solved the problem of getting the object id being edited using this code:
class CompanyUserInline(admin.StackedInline):
\"\"\"
Defines
The following code snippet will give you the object id:
request.resolver_match.kwargs['object_id']
Sample usage: (I'm filtering the phone numbers shown, to only show customer's phone numbers)
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'preferred_contact_number':
kwargs['queryset'] = CustomerPhone.objects.filter(customer__pk=request.resolver_match.kwargs['object_id'])
return super().formfield_for_foreignkey(db_field, request, **kwargs)
P.S: Found it by debugging and walking through accessible variables.