The previous approach using complex if-else expressions in t-set variables
was causing QWeb parsing issues (TypeError: 'NoneType' object is not callable).
Solution: Leverage Python's 'or' operator in t-set variable computation
- Create intermediate variable: display_price_value = price_info.get('price')
- Then compute: display_price = display_price_value or product.list_price or 0.0
- Use simple reference in t-attf attribute: {{ display_price }}
This approach:
1. Avoids complex nested conditionals in t-set
2. Uses Python's native short-circuit evaluation for None-safety
3. Keeps template expressions simple and readable
4. Properly handles fallback values in the right evaluation order
Testing: Module loads without errors, template renders successfully.
|
||
|---|---|---|
| .. | ||
| group_order_views.xml | ||
| load_from_history_templates.xml | ||
| portal_templates.xml | ||
| product_template_views.xml | ||
| res_config_settings_views.xml | ||
| res_partner_views.xml | ||
| sale_order_views.xml | ||
| stock_picking_views.xml | ||
| website_templates.xml | ||