---
name: odoo-qweb-html
description: HTML/CSS/QWeb conventions for this repo (web templates, moving logic to the controller, styling). Use when editing QWeb templates, web views, or CSS in Odoo addons (website_sale_aplicoop).
metadata:
  type: reference
---

# HTML & CSS (Odoo/QWeb)

## Golden rule
**QWeb has strict limitations with complex logic.** Prepare ALL data in the Python controller
and use only simple attribute access in the template. This avoids errors like
`TypeError: 'NoneType' object is not callable`.

```python
# ❌ BAD — QWeb does not reliably parse this
# <t t-set="price" t-value="info.get('price') or product.list_price or 0"/>

# ✅ GOOD — pre-process in the controller
def _prepare_product_display_info(self, product, price_info):
    price = price_info.get(product.id, {}).get('price') or product.list_price or 0.0
    return {'display_price': float(price), 'safe_uom': product.uom_id.category_id.name or ''}
```
```xml
<!-- In template: simple access, no conditionals -->
<span t-esc="product_display['display_price']"/>
```

## Style and conventions
- Valid HTML5. 4-space indentation.
- CSS: BEM or utility classes / Bootstrap when available. **No inline styles** except in well-justified cases.
- Templates in `views/*.xml` or `static/src/xml/`. Styles in `static/src/css/` (load in manifest if needed).

## Reference
- `docs/QWEB_BEST_PRACTICES.md` for full logic/template separation patterns.
