# Quickstart — Spec 027 Matriz de Funções

**Status:** Draft — Fase 2 pendente  
**Depende de:** Spec 003, 004, 015, 024

---

## Funções comercial (Roger)

| ID | Label | FOSS | Odoo | OpenPanel |
|----|-------|------|------|-----------|
| `sales_admin` | Sales Admin — Gerente | grupo `ligbox-sales-admin` | Sales Manager | OpenAdmin Admin |
| `sales_support` | Sales Support — Analista | grupo `ligbox-sales-support` | Salesman | autologin só |

---

## Validar matriz

1. `specs/027-desk-rbac-function-matrix/spec.md` — secções 2–4.1
2. `contracts/vm123-product-roles.md` — APIs FOSS, Odoo, OpenPanel

---

## Criar grupos FOSS (VM123 — manual v1)

1. Login `https://financeiro.ligbox.com.br/admin`
2. **Extensions → Staff → Groups** — criar:
   - `ligbox-sales-admin` (client, order, invoice, support — sem staff settings)
   - `ligbox-sales-support` (client, order, support — read-only invoice)
   - `ligbox-finance-admin` (full finance modules)

---

## Teste API FOSS (LAN)

```bash
curl -s -X POST "https://financeiro.ligbox.com.br/api/admin/client/get_list" \
  -H "Authorization: Basic $(echo -n 'admin:FOSS_API_KEY' | base64)" \
  -H "Content-Type: application/json" \
  -d '{"per_page":5}'
```

---

## Teste Odoo XML-RPC

```python
import xmlrpc.client
common = xmlrpc.client.ServerProxy("https://financeiro.ligbox.com.br/odoo/xmlrpc/2/common")
uid = common.authenticate("ligbox", "admin@ligbox.com.br", "API_KEY", {})
models = xmlrpc.client.ServerProxy("https://financeiro.ligbox.com.br/odoo/xmlrpc/2/object")
print(models.execute_kw("ligbox", uid, "API_KEY", "res.users", "search_read", [[("login","=","admin@ligbox.com.br")]], {"fields":["groups_id"]}))
```

---

## Teste OpenPanel bridge

```bash
# Token
curl -s -X POST "http://10.10.10.123:18087/api" \
  -H "Content-Type: application/json" \
  -d '{"username":"ligboxadmin","password":"..."}'

# List (Community bridge — GET /api health)
curl -s -H "Authorization: Bearer BRIDGE_TOKEN" "http://10.10.10.123:18087/api"
```

---

## Checklist Fase 2 Desk

- [x] `sales_admin` / `sales_support` no dropdown approve (Spec 004)
- [x] `permissions.py` + `can_create_foss_order`
- [x] Módulos default por função (secção 7 spec)
- [x] Drawer VM123 deep-links (`/api/v1/vm123/links/client`)
- [ ] Grupos FOSS criados manualmente na VM123
- [x] Apps Odoo `crm` + `sale` + `account` instaladas na VM123 (`install-odoo-apps.sh`)

---

## Resumo ambientes

| Função | VM112 | VM122 | VM123 |
|--------|-------|-------|-------|
| Sales Admin | 🔒 | billing ✅ leads ✅ | FOSS+Odoo ✅ |
| Sales Support | 🔒 | leads ✅ | FOSS pedidos ✅ Odoo user |
| Financeiro | 🔒 | billing ✅ | FOSS+Odoo ✅ |
