Overview
PTE status tracking operates at two levels: PTE-level status (the overall project) and step-level status (individual workflow tasks). This guide focuses on PTE-level status management.PTE Status Choices
ThePTEHeader model defines four primary statuses:
1 - Activo
1 - Activo
Initial Status: The PTE has been created and is ready to begin work.
- PTE has been approved and initialized
- Workflow steps have been generated
- No active work has started yet
- Can transition to: En Proceso, Cancelado
2 - En Proceso
2 - En Proceso
Active Work: Work is actively being performed on the PTE.
- One or more steps are in progress
- Team members are actively working
- Progress is being tracked
- Can transition to: Terminado, Cancelado, Suspendido (9)
3 - Terminado
3 - Terminado
Completed: All work has been completed and the PTE is ready for OT generation.
- All required steps are completed
fecha_entregais automatically set- PTE is ready to create an OT (Orden de Trabajo)
- This is a terminal state for successful PTEs
4 - Cancelado
4 - Cancelado
Cancelled: The PTE has been cancelled and will not proceed.
- Work has been stopped
- No OT will be generated
- PTE is archived
- This is a terminal state
There’s also an undocumented status
9 - SUSPENDIDA visible in the datatable annotation, indicating suspended PTEs.Changing PTE Status
Thecambiar_estatus_pte function handles PTE-level status updates:
URL: /pte/cambiar_estatus_pte/Method:
POSTAuthentication: Required
Activity Logging: Enabled
Parameters
ID of the PTE to update
New status value (1, 2, 3, 4, or 9)
Optional comment explaining the status change
Optional delivery date (auto-set to now if not provided when status=3)
Implementation
Dashboard Statistics
The main index view provides PTE statistics by status: URL:/ (root)View Function:
pte.index
The total count excludes logically deleted PTEs (status=0) by explicitly filtering for statuses 1-4.
Status Display in DataTables
Thedatatable_ptes function annotates PTEs with human-readable status text:
Notice the slight naming differences:
- Model: “Activo” → DataTable: “PENDIENTE”
- Model: “Terminado” → DataTable: “ENTREGADA”
Filtering by Status
The DataTables endpoint supports filtering by status:Additional Filters
Beyond status, the DataTables endpoint supports multiple filters:| Parameter | Description | Example |
|---|---|---|
estatus | Filter by status ID | ?estatus=2 |
tipo[] | Filter by PTE type (multi) | ?tipo[]=1&tipo[]=3 |
responsable_proyecto | Filter by project manager | ?responsable_proyecto=5 |
anio | Filter by year in oficio | ?anio=2024 |
cliente | Filter by client | ?cliente=3 |
filtro | General search text | ?filtro=instalacion |
Year Filtering Logic
The year filter uses regex to extract the year from theoficio_pte field:
Progress Integration
While status indicates the overall state, progress shows completion percentage:A PTE can have status “En Proceso” (2) with 85% progress, or status “Terminado” (3) with 100% progress. The two metrics are complementary.
Logical Deletion
The system uses logical deletion rather than physical deletion:OT Creation Validation
When creating an OT from a PTE, the system validates completion status:The PTE must have 100% step completion (all steps with status 3, 4, or 14) to generate an OT, regardless of the PTE’s own status field.
Response Examples
Success Response
Error Responses
API Endpoints Summary
| Endpoint | Method | Purpose |
|---|---|---|
/pte/cambiar_estatus_pte/ | POST | Change PTE status |
/pte/datatable/ | GET | Get filtered PTE list |
/pte/obtener_datos/ | GET | Get PTE details for editing |
/pte/eliminar/ | POST | Logical deletion (status=0) |
/ | GET | Dashboard with status counts |
Best Practices
Always Validate Progress
Before marking a PTE as “Terminado”, verify that all workflow steps are completed
Use Logical Deletion
Never physically delete PTEs; use status=0 for historical data preservation
Track Status Changes
The
@registrar_actividad decorator logs all status changes for audit trailsEnforce Permissions
Always check user permissions before allowing status changes or deletions
Related Topics
Workflow Steps
Learn about step-level status management
Creating PTEs
Understand PTE initialization and defaults