0

I have the following models:

class Provider(models.Model):
    name = models.CharField()
    ...

class Article(models.Model):
    provider = models.ManyToManyField(Provider)
    ...

class Invoice(models.Model):
    provider = models.ForeignKey(Provider)
    ...

class ArticleInvoice(models.Model):
    article = models.ForeignKey(Article)
    invoice = models.ForeignKey(Invoice)
    ... #qty, status, etc

and my admin looks like:

class ArticleInvoiceInline(admin.TabularInline):
    model = ArticleInvoice

class InvoiceAdmin(models.Model):
    inlines = [ArticleInvoiceInline]

admin.site.register(Invoice, InvoiceAdmin)

The problem:

When i create an Invoice i have to chose a Provider, then add some ArticleInvoices, the ArticleInvoice have an Article wich has a Provider, when i choose the Article for the ArticleInvoice it shows all the articles.

I would like to apply a filter so i can only create ArticleInvoices in the InvoiceAdmin with Articles that have the same Provider as the Invoice

J. Doe
  • 1
  • 1
  • 1

0 Answers0