{
  "version": "1.0.0",
  "workflow_name": "OTO Vente Pipeline",
  "document_type": "OTO Dossier Vente",
  "document_type_custom": true,
  "workflow_state_field": "workflow_state",
  "is_active": 1,
  "send_email_alert": 0,
  "override_status": 0,
  "_comment": "Pipeline commercial OTO (roadmap Sprint 4 · CRM natif ERPNext) : lead -> visite -> devis -> reservation -> contrat -> CONFOTUR. Les roles (`allow_edit`/`allowed`) referencent l'`id` d'un role du contrat rbac_50_roles.json (reutilisation, zero duplication · #6) ; le builder resout id -> erpnext_role_name. doc_status : 0=Brouillon, 1=Soumis, 2=Annule (monotone le long des transitions, natif Frappe).",
  "states": [
    {
      "state": "Lead",
      "doc_status": "0",
      "role_id": "ventes-conseiller",
      "style": "Primary",
      "update_value": "lead",
      "is_terminal": false,
      "message": "Nouveau prospect qualifie a contacter."
    },
    {
      "state": "Visite planifiée",
      "doc_status": "0",
      "role_id": "ventes-conseiller",
      "style": "Info",
      "update_value": "visite",
      "is_terminal": false,
      "message": "Visite du site ou de l'unite temoin programmee."
    },
    {
      "state": "Devis émis",
      "doc_status": "0",
      "role_id": "ventes-conseiller",
      "style": "Warning",
      "update_value": "devis",
      "is_terminal": false,
      "message": "Devis chiffre remis au prospect (attente decision)."
    },
    {
      "state": "Réservation confirmée",
      "doc_status": "1",
      "role_id": "ventes-reservations",
      "style": "Primary",
      "update_value": "reservation",
      "is_terminal": false,
      "message": "Depot de reservation encaisse ; dossier verrouille (soumis)."
    },
    {
      "state": "Contrat signé",
      "doc_status": "1",
      "role_id": "ventes-contrats",
      "style": "Success",
      "update_value": "contrat",
      "is_terminal": false,
      "message": "Contrat de vente signe par les deux parties."
    },
    {
      "state": "CONFOTUR déposé",
      "doc_status": "1",
      "role_id": "ventes-confotur",
      "style": "Info",
      "update_value": "confotur_depose",
      "is_terminal": false,
      "message": "Dossier d'incitation CONFOTUR depose aupres de l'autorite."
    },
    {
      "state": "CONFOTUR approuvé",
      "doc_status": "1",
      "role_id": "ventes-confotur",
      "style": "Success",
      "update_value": "confotur_approuve",
      "is_terminal": true,
      "message": "Incitation CONFOTUR approuvee ; cycle de vente clos avec succes."
    },
    {
      "state": "Abandonné",
      "doc_status": "0",
      "role_id": "ventes-chef-equipe",
      "style": "Danger",
      "update_value": "abandonne",
      "is_terminal": true,
      "message": "Piste abandonnee avant reservation (brouillon)."
    },
    {
      "state": "Perdu",
      "doc_status": "2",
      "role_id": "ventes-directeur",
      "style": "Danger",
      "update_value": "perdu",
      "is_terminal": true,
      "message": "Affaire soumise resiliee/annulee (dossier annule)."
    }
  ],
  "transitions": [
    {
      "state": "Lead",
      "action": "Planifier visite",
      "next_state": "Visite planifiée",
      "role_id": "ventes-conseiller",
      "allow_self_approval": 1
    },
    {
      "state": "Lead",
      "action": "Abandonner",
      "next_state": "Abandonné",
      "role_id": "ventes-conseiller",
      "allow_self_approval": 1
    },
    {
      "state": "Visite planifiée",
      "action": "Émettre devis",
      "next_state": "Devis émis",
      "role_id": "ventes-conseiller",
      "allow_self_approval": 1
    },
    {
      "state": "Visite planifiée",
      "action": "Abandonner",
      "next_state": "Abandonné",
      "role_id": "ventes-conseiller",
      "allow_self_approval": 1
    },
    {
      "state": "Devis émis",
      "action": "Abandonner",
      "next_state": "Abandonné",
      "role_id": "ventes-chef-equipe",
      "allow_self_approval": 1
    },
    {
      "state": "Devis émis",
      "action": "Confirmer réservation",
      "next_state": "Réservation confirmée",
      "role_id": "ventes-reservations",
      "allow_self_approval": 0,
      "separation_of_duties": true
    },
    {
      "state": "Réservation confirmée",
      "action": "Signer contrat",
      "next_state": "Contrat signé",
      "role_id": "ventes-contrats",
      "allow_self_approval": 0,
      "separation_of_duties": true
    },
    {
      "state": "Réservation confirmée",
      "action": "Annuler (perdu)",
      "next_state": "Perdu",
      "role_id": "ventes-directeur",
      "allow_self_approval": 0,
      "separation_of_duties": true
    },
    {
      "state": "Contrat signé",
      "action": "Déposer CONFOTUR",
      "next_state": "CONFOTUR déposé",
      "role_id": "ventes-confotur",
      "allow_self_approval": 1
    },
    {
      "state": "Contrat signé",
      "action": "Résilier (perdu)",
      "next_state": "Perdu",
      "role_id": "direction-cco",
      "allow_self_approval": 0,
      "separation_of_duties": true
    },
    {
      "state": "CONFOTUR déposé",
      "action": "Approuver CONFOTUR",
      "next_state": "CONFOTUR approuvé",
      "role_id": "ventes-confotur",
      "allow_self_approval": 0,
      "separation_of_duties": true
    }
  ]
}
