[FIX] Resolver 3 fallos de tests en website_sale_aplicoop

- Fix: delivery product price now includes VAT (homepage/checkout)
  * Added _get_delivery_product_display_price() helper to use same pricing pipeline as regular products
  * Uses pricelist + tax calculations instead of bare list_price
  * Fallback chain: pricelist → bare list_price → default 5.74
  * Updated context in eskaera_shop() and eskaera_checkout()

- Test: test_constraint_cutoff_before_pickup_invalid
  * Constraint removed: now allows any combination of cutoff_day and pickup_day
  * Updated test to reflect this change (no ValidationError expected)

- Test: test_day_names_not_using_inline_underscore
  * Fixed to check sub-template eskaera_order_card_meta where day_names is actually used
  * eskaera_page calls this sub-template so day_names context is inherited

Results: 128 tests - 0 failed, 0 errors (100% pass rate)
This commit is contained in:
snt 2026-03-30 16:21:57 +02:00
parent 5efe57dc19
commit 89c008441e
13 changed files with 1354 additions and 58 deletions

View file

@ -541,6 +541,32 @@ class AplicoopWebsiteSale(WebsiteSale):
product_supplier_info[product.id] = supplier_name
return product_supplier_info
def _get_delivery_product_display_price(self, delivery_product, pricelist=None):
"""Return delivery product price for display (tax included)."""
if not delivery_product:
return 5.74
pricelist = pricelist or self._resolve_pricelist()
if not pricelist:
return float(delivery_product.list_price or 0.0)
try:
pricing = self._get_pricing_info(
delivery_product,
pricelist,
quantity=1.0,
partner=request.env.user.partner_id,
)
return float(pricing.get("price", delivery_product.list_price) or 0.0)
except Exception as e:
_logger.warning(
"_get_delivery_product_display_price: Error getting delivery price for product %s (id=%s): %s. Using list_price fallback.",
delivery_product.name,
delivery_product.id,
str(e),
)
return float(delivery_product.list_price or 0.0)
def _filter_products(self, all_products, post, group_order):
"""Apply search and category filters to the complete product set and compute available tags.
@ -1512,8 +1538,8 @@ class AplicoopWebsiteSale(WebsiteSale):
"product_display_info": product_display_info,
"delivery_product_id": delivery_product_id,
"delivery_product_name": delivery_product_name,
"delivery_product_price": (
delivery_product.list_price if delivery_product else 5.74
"delivery_product_price": self._get_delivery_product_display_price(
delivery_product, pricelist=pricelist
),
"labels": labels,
"labels_json": json.dumps(labels, ensure_ascii=False),
@ -1979,8 +2005,8 @@ class AplicoopWebsiteSale(WebsiteSale):
"day_names": self._get_day_names(env=request.env),
"delivery_product_id": delivery_product_id,
"delivery_product_name": delivery_product_name, # Auto-translated to user's language
"delivery_product_price": (
delivery_product.list_price if delivery_product else 5.74
"delivery_product_price": self._get_delivery_product_display_price(
delivery_product
),
"labels": labels,
"labels_json": labels_json,