Merge pull request #1177 from ae-utbm/fix_archived_products

Fix display of archived products
This commit is contained in:
Kenneth Soares
2025-09-19 20:09:40 +02:00
committed by GitHub
2 changed files with 14 additions and 2 deletions

View File

@@ -683,8 +683,10 @@ class Counter(models.Model):
Prices will be annotated
"""
products = self.products.select_related("product_type").prefetch_related(
"buying_groups"
products = (
self.products.filter(archived=False)
.select_related("product_type")
.prefetch_related("buying_groups")
)
# Only include age appropriate products

View File

@@ -583,6 +583,16 @@ class TestCounterClick(TestFullClickBase):
- self.beer.selling_price
)
def test_no_fetch_archived_product(self):
counter = baker.make(Counter)
customer = baker.make(Customer)
product_recipe.make(archived=True, counters=[counter])
unarchived_products = product_recipe.make(
archived=False, counters=[counter], _quantity=3
)
customer_products = counter.get_products_for(customer)
assert unarchived_products == customer_products
class TestCounterStats(TestCase):
@classmethod