Updated documentation to reflect the final, working solution:
Key changes:
- Clarified the three-step pattern: Extract → Fallback → Use
- Documented why complex conditionals in t-set fail
- Explained why intermediate variables are the solution
- Added detailed Git commit history (df57233, 0a0cf5a, 8e5a4a3)
- Included QWeb rendering limitations and best practices
The solution uses Python's native 'or' operator with intermediate variables,
avoiding complex conditionals that QWeb can't parse reliably.
Pattern:
1. Extract value: display_price_value = price_info.get('price')
2. Apply fallbacks: display_price = display_price_value or product.list_price or 0.0
3. Use in template: t-attf-data-price="{{ display_price }}"
This approach is simple, reliable, and follows QWeb best practices.
- FIX_TEMPLATE_ERROR_SUMMARY.md: Complete analysis of the website_sale_aplicoop template error and its resolution
* Root cause: QWeb parsing issues with 'or' operators in t-attf-* attributes
* Solution: Pre-compute safe variables using t-set before form element
* Verification: Template loads successfully, variables render correctly
* Git commits: df57233 (first attempt), 0a0cf5a (final fix)
- QWEB_BEST_PRACTICES.md: Comprehensive guide for QWeb template development
* Attribute expression best practices
* None/null safety patterns (3 patterns with examples)
* Variable computation patterns (3 patterns with examples)
* Common pitfalls and solutions
* Real-world examples (e-commerce, nested data, conditional styling)
* Summary table and validation tools
These documents provide immediate reference for QWeb issues and establish
standards for template development in Odoo 18 projects.