django-smart-selects icon indicating copy to clipboard operation
django-smart-selects copied to clipboard

Chaining not working in inlines in ChainedManyToManyField with horizontal=True parameter

Open KaktusOnFire opened this issue 2 years ago • 1 comments

Checklist

Put an x in the bracket when you have completed each task, like this: [x]

  • [x] This issue is not about installing previous versions of django-smart-selects older than 1.2.8. I understand that previous versions are insecure and will not receive any support whatsoever.
  • [x] I have verified that that issue exists against the master branch of django-smart-selects.
  • [x] I have debugged the issue to the smart_selects app.
  • [x] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [x] I have reduced the issue to the simplest possible case.
  • [x] I have included all relevant sections of models.py, forms.py, and views.py with problems.
  • [x] I have used GitHub Flavored Markdown to style all of my posted code.

Steps to reproduce

  1. Create inline
  2. Add chainedmanytomany field with horizontal=True parameter
  3. Try to pick any of ProductGroup values

Actual behavior

Get chained values only for product and tariff p.s. everything works OK ONLY when i'm press save and trying to change EXISTING object image

Expected behavior

Get chained values for product, tariff and discounts

image

Model structure


    product_group = models.ForeignKey(ProductGroup, on_delete=models.RESTRICT, default=None, null=True)
    product = ChainedForeignKey(Product,
                                chained_field="product_group",
                                chained_model_field="product_group",
                                show_all=False,
                                auto_choose=True,
                                sort=True,
                                default=None
                                )
    tariff = ChainedForeignKey("Tariff",
                               chained_field="product_group",
                               chained_model_field="product_group",
                               show_all=False,
                               auto_choose=True,
                               sort=True,
                               default=None
                               )
    discounts = ChainedManyToManyField("Discount",
                                       chained_field="product_group",
                                       chained_model_field="product_groups",
                                       default=None,
                                       blank=True,
                                       )

Console log after picking ProductGroup value

2023-06-15 16:38:11 | INFO/MainProcess | "GET /chaining/filter/crm/Tariff/product_group/crm/UserInvoiceItem/tariff/68/ HTTP/1.1" 200 286
2023-06-15 16:38:11 | INFO/MainProcess | "GET /chaining/filter/crm/Product/product_group/crm/UserInvoiceItem/product/68/ HTTP/1.1" 200 1071

Log should contains request for discounts field, but its not.

KaktusOnFire avatar Jun 15 '23 13:06 KaktusOnFire

Any suggestions?

KaktusOnFire avatar Dec 06 '23 13:12 KaktusOnFire