Skip to main content

Overview

The Projects module enables you to manage client contracts, track resource assignments, and monitor project lifecycles from initiation to closure. Each project is associated with a partner (client) and maintains complete audit trails of all resources and activities.

Core Models

Project

Represents a service contract with a client. Projects remain active until explicitly closed and serve as the parent container for all resource assignments and work activities.

Partner Association

Each project is linked to a Partner (client) who is billed for services

Location Tracking

Track campamento (location) and cardinal points (NORTE, SUR, ESTE, OESTE, etc.)

Contact Management

Store contact name and phone number for on-site coordination

Lifecycle Control

Manage start_date, end_date, and is_closed status

Key Fields

class Project(BaseModel):
    id = AutoField(primary_key=True)
    partner = ForeignKey('projects.Partner', on_delete=PROTECT)
    location = CharField(max_length=50)  # Campamento
    cardinal_point = CharField(
        max_length=20,
        choices=[
            'NORTE', 'SUR', 'ESTE', 'OESTE',
            'NORESTE', 'NOROESTE', 'SURESTE', 'SUROESTE'
        ]
    )
    contact_name = CharField(max_length=255)
    contact_phone = CharField(max_length=15)
    start_date = DateField()
    end_date = DateField(blank=True, null=True)
    is_closed = BooleanField(default=False)
Projects use logical deletion (is_deleted from BaseModel) to preserve historical records. The is_closed field controls whether new resources can be assigned.

Project Resource Assignment

ProjectResourceItem

Links physical equipment (ResourceItem) to projects with rental costs, maintenance scheduling, and operational date ranges.
  • Cost Tracking: Separate fields for rental cost and maintenance cost
  • Maintenance Scheduling: Frequency-based scheduling with three modes
  • Operation Dates: Track when equipment enters and exits service
  • Retirement Tracking: Record retirement date and reason when equipment is removed

Frequency-Based Maintenance Scheduling

The system supports three scheduling modes:

Interval Days

frequency_type = ‘DAY’Maintenance every N daysinterval_days = 2 means every 2 days

Weekdays

frequency_type = ‘WEEK’Specific days of the weekweekdays = [0, 2, 4] means Monday, Wednesday, Friday

Month Days

frequency_type = ‘MONTH’Specific days of the monthmonthdays = [1, 15, 28] means 1st, 15th, and 28th

Code Example: Assigning Resources

from projects.models import Project, ProjectResourceItem
from equipment.models import ResourceItem

# Assign a resource to a project with weekly maintenance
resource_assignment = ProjectResourceItem.objects.create(
    project=project,
    resource_item=resource,
    type_resource='EQUIPO',
    physical_equipment_code=101,
    cost=250.00,
    frequency_type='WEEK',
    weekdays=[0, 3],  # Monday and Thursday
    operation_start_date='2026-01-15',
    operation_end_date='2026-06-30'
)

# Get all resources for a project
resources = ProjectResourceItem.get_by_project(project_id=1)

Project Lifecycle

1. Project Creation

1

Create Project

Initialize project with partner, location, contact details, and start date
2

Assign Resources

Link equipment and services via ProjectResourceItem with cost and schedule
3

Track Operations

Monitor resource status, maintenance activities, and work orders
4

Close Project

Set is_closed = True when project is complete (data is preserved)

2. Resource Retirement

When equipment needs to be removed from a project:
# Mark resource as retired
resource_assignment.is_retired = True
resource_assignment.retirement_date = datetime.date.today()
resource_assignment.retirement_reason = "Equipment damaged, needs repair"
resource_assignment.save()
The system uses PROTECT on foreign key relationships. You cannot delete a Partner or ResourceItem if it’s referenced by an active ProjectResourceItem.

Data Model Reference

ProjectResourceItem Fields

FieldTypeDescription
projectForeignKeyReference to Project
resource_itemForeignKeyReference to ResourceItem (equipment)
type_resourceCharField’EQUIPO’ or ‘SERVICIO’
detailed_descriptionCharFieldAdditional details (max 120 chars)
physical_equipment_codePositiveSmallIntegerFieldPhysical identifier code
costDecimalFieldRental or service cost
frequency_typeCharField’DAY’, ‘WEEK’, or ‘MONTH’
interval_daysPositiveIntegerFieldDays between maintenance (when frequency_type=‘DAY’)
weekdaysJSONFieldList of weekdays [0-6] (when frequency_type=‘WEEK’)
monthdaysJSONFieldList of month days [1-31] (when frequency_type=‘MONTH’)
operation_start_dateDateFieldWhen equipment enters service
operation_end_dateDateFieldWhen equipment exits service
is_retiredBooleanFieldWhether equipment has been removed
retirement_dateDateFieldDate equipment was removed
retirement_reasonTextFieldReason for removal

Cardinal Points Reference

Projects support the following cardinal directions for location tracking:
  • NORTE (North)
  • SUR (South)
  • ESTE (East)
  • OESTE (West)
  • NORESTE (Northeast)
  • NOROESTE (Northwest)
  • SURESTE (Southeast)
  • SUROESTE (Southwest)

Best Practices

  • Always set operation_start_date and operation_end_date for tracking
  • Use is_retired instead of deleting ProjectResourceItem records
  • Document retirement reasons for audit trail
  • Choose frequency_type based on client requirements
  • Use ‘DAY’ for simple intervals (every 2 days, every 7 days)
  • Use ‘WEEK’ for specific weekdays (Monday/Wednesday/Friday)
  • Use ‘MONTH’ for monthly schedules (1st and 15th of month)
  • Set is_closed = True instead of deleting projects
  • Retire all resources before closing project
  • Ensure all work orders and custody chains are finalized

Equipment

Manage the resource items assigned to projects

Work Orders

Track work activities on project resources

Custody Chains

Document responsibility transfers and waste handling

Maintenance

Schedule and track equipment maintenance