Open Source CRM developed on Django framework with REST API for contact, lead, account, and opportunity management
Customer account management functionality for companies and organizations in the CRM system. Accounts represent business entities that can have multiple contacts, opportunities, cases, and other CRM activities associated with them.
List accounts with comprehensive filtering and search capabilities.
def list_accounts(name: str = None, city: str = None, industry: str = None,
tags: str = None, limit: int = 10, offset: int = 0) -> dict:
"""
List accounts with filtering and search.
Args:
name (str, optional): Filter by account name (partial match)
city (str, optional): Filter by city
industry (str, optional): Filter by industry
tags (str, optional): Filter by tags
limit (int): Number of results per page (default: 10)
offset (int): Number of results to skip (default: 0)
Returns:
dict: Paginated accounts with metadata
Headers Required:
Authorization: Bearer <access_token>
organization-id: <org_uuid>
Example:
GET /api/accounts/?name=acme&city=new%20york&limit=5
Response:
{
"open_accounts": [
{
"id": "account-uuid",
"name": "ACME Corporation",
"email": "contact@acme.com",
"phone": "+1234567890",
"industry": "Technology",
"billing_address_line": "123 Business St",
"billing_city": "New York",
"billing_state": "NY",
"billing_postcode": "10001",
"billing_country": "USA",
"website": "https://acme.com",
"status": "open",
"created_on": "2023-01-15T10:30:00Z",
"created_by": "user-uuid",
"assigned_to": ["user1-uuid"],
"teams": ["team1-uuid"],
"tags": ["enterprise", "technology"]
}
],
"closed_accounts": [],
"accounts_count": 1,
"open_accounts_count": 1,
"closed_accounts_count": 0,
"contacts": [...],
"users": [...],
"teams": [...]
}
"""Create new accounts with full business information and associations.
def create_account(account_data: dict) -> dict:
"""
Create a new account.
Args:
account_data (dict): Account information and associations
Returns:
dict: Created account details
Headers Required:
Authorization: Bearer <access_token>
organization-id: <org_uuid>
Content-Type: multipart/form-data (if including attachments)
Example:
POST /api/accounts/
{
"name": "New Company Inc",
"email": "info@newcompany.com",
"phone": "+1555123456",
"industry": "Manufacturing",
"description": "Leading manufacturer of widgets",
"website": "https://newcompany.com",
"billing_address_line": "456 Industrial Blvd",
"billing_street": "Suite 100",
"billing_city": "Chicago",
"billing_state": "IL",
"billing_postcode": "60601",
"billing_country": "USA",
"contacts": ["contact1-uuid", "contact2-uuid"],
"assigned_to": ["user1-uuid"],
"teams": ["team1-uuid"],
"tags": ["manufacturing", "enterprise"]
}
Response:
{
"id": "new-account-uuid",
"name": "New Company Inc",
...account details...
}
"""Get comprehensive account information including all related entities.
def get_account(pk: str) -> dict:
"""
Get detailed account information.
Args:
pk (str): Account UUID
Returns:
dict: Complete account details with related entities
Headers Required:
Authorization: Bearer <access_token>
organization-id: <org_uuid>
Example:
GET /api/accounts/account-uuid/
Response:
{
"account_obj": {
"id": "account-uuid",
"name": "ACME Corporation",
"email": "contact@acme.com",
"phone": "+1234567890",
"industry": "Technology",
"description": "Leading technology company",
"website": "https://acme.com",
"status": "open",
"billing_address_line": "123 Business St",
"billing_city": "New York",
"billing_state": "NY",
"billing_postcode": "10001",
"billing_country": "USA",
"created_on": "2023-01-15T10:30:00Z",
"created_by": "user-uuid"
},
"contacts": [...list of associated contacts...],
"opportunities": [...list of opportunities...],
"cases": [...list of cases...],
"tasks": [...list of tasks...],
"invoices": [...list of invoices...],
"assigned_to": [...list of assigned users...],
"teams": [...list of assigned teams...],
"comments": [...list of comments...],
"attachments": [...list of attachments...],
"users_mention": [...users for @mentions...],
"tags": ["enterprise", "technology"]
}
"""
def update_account(pk: str, account_data: dict) -> dict:
"""
Update account information.
Args:
pk (str): Account UUID
account_data (dict): Updated account information
Returns:
dict: Updated account details
Headers Required:
Authorization: Bearer <access_token>
organization-id: <org_uuid>
Example:
PUT /api/accounts/account-uuid/
{
"name": "ACME Corporation Ltd",
"phone": "+1234567891",
"website": "https://acme.com"
}
"""
def delete_account(pk: str) -> None:
"""
Delete an account.
Args:
pk (str): Account UUID
Returns:
None: 204 No Content on success
Headers Required:
Authorization: Bearer <access_token>
organization-id: <org_uuid>
Example:
DELETE /api/accounts/account-uuid/
"""Add comments and file attachments to accounts.
def add_account_comment_or_attachment(pk: str, comment: str = None,
attachment: file = None) -> dict:
"""
Add comment or attachment to account.
Args:
pk (str): Account UUID
comment (str, optional): Comment text
attachment (file, optional): File to attach
Returns:
dict: Success response with added comment/attachment
Headers Required:
Authorization: Bearer <access_token>
organization-id: <org_uuid>
Content-Type: multipart/form-data (for attachments)
Example:
POST /api/accounts/account-uuid/
{
"comment": "Follow-up meeting scheduled for next week"
}
# Or with file attachment
FormData:
comment: "Contract document attached"
attachment: <file_object>
"""
def edit_account_comment(pk: str, comment: str) -> dict:
"""
Edit an account comment.
Args:
pk (str): Comment UUID
comment (str): Updated comment text
Returns:
dict: Updated comment
Headers Required:
Authorization: Bearer <access_token>
Example:
PUT /api/accounts/comment/comment-uuid/
{
"comment": "Updated comment text"
}
"""
def delete_account_comment(pk: str) -> None:
"""
Delete an account comment.
Args:
pk (str): Comment UUID
Returns:
None: 204 No Content on success
Headers Required:
Authorization: Bearer <access_token>
Example:
DELETE /api/accounts/comment/comment-uuid/
"""
def delete_account_attachment(pk: str) -> None:
"""
Delete an account attachment.
Args:
pk (str): Attachment UUID
Returns:
None: 204 No Content on success
Headers Required:
Authorization: Bearer <access_token>
Example:
DELETE /api/accounts/attachment/attachment-uuid/
"""Send emails from accounts with scheduling and tracking capabilities.
def create_account_email(pk: str, email_data: dict) -> dict:
"""
Send email from account.
Args:
pk (str): Account UUID
email_data (dict): Email details including recipients, subject, body
Returns:
dict: Email sent confirmation
Headers Required:
Authorization: Bearer <access_token>
organization-id: <org_uuid>
Example:
POST /api/accounts/account-uuid/create_mail/
{
"recipients": ["contact@client.com", "manager@client.com"],
"subject": "Quarterly Business Review",
"html": "<p>Dear valued client...</p>",
"scheduled_later": false,
"scheduled_date_time": null,
"from_account": "sender@yourcompany.com"
}
Response:
{
"status": "success",
"message": "Email sent successfully",
"email_id": "email-uuid"
}
"""class Account:
"""Account model representing a customer company/organization"""
id: str # UUID
name: str # Company name (required)
email: str # Primary email
phone: str # Primary phone
industry: str # Industry type
description: str # Company description
website: str # Company website URL
status: str # 'open' or 'closed'
# Billing address
billing_address_line: str
billing_street: str
billing_city: str
billing_state: str
billing_postcode: str
billing_country: str
# Metadata
created_on: datetime
created_by: str # User UUID
org: str # Organization UUID
# Associations
contacts: list[str] # Contact UUIDs
assigned_to: list[str] # User UUIDs
teams: list[str] # Team UUIDs
tags: list[str] # Tag names
class AccountStatus:
"""Account status options"""
OPEN: str = "open"
CLOSED: str = "closed"
class AccountComment:
"""Comments on accounts"""
id: str # UUID
comment: str
account: str # Account UUID
commented_on: datetime
commented_by: str # User UUID
class AccountAttachment:
"""File attachments on accounts"""
id: str # UUID
attachment: str # File path/URL
account: str # Account UUID
created_on: datetime
created_by: str # User UUIDAccounts support extensive filtering options:
name (partial matching)city filteringindustry filteringtags filtering for custom categorizationAll filters can be combined and are case-insensitive where applicable.
Accounts serve as central hubs connecting to:
These relationships provide comprehensive account management and activity tracking across all CRM functions.
Install with Tessl CLI
npx tessl i tessl/pypi-django-crm