File Management models
- DocumentTemplate
- DocumentTemplateHeader
- FileNode
- FileReference · Internal
- Page
- SignatureRecipient · Internal
- SignatureRequest
- SignatureRequestField · Internal
Column and nullable values apply to fields stored on the model's table.
DocumentTemplate
bloomerp.models.document_templates.document_template.DocumentTemplate
A text based template that can be re-used to generate PDF's, Emails, ...
Database table bloomerp_document_template
| Field | Type | Column | Nullable | Description |
|---|---|---|---|---|
id | UUIDField | id | No | — |
datetime_created | DateTimeField | datetime_created | No | — |
datetime_updated | DateTimeField | datetime_updated | No | — |
created_by | UserField to bloomerp.User | created_by_id | Yes | — |
updated_by | UserField to bloomerp.User | updated_by_id | Yes | — |
default_signature_layout | ForeignKey to bloomerp.SignatureLayout | default_signature_layout_id | Yes | Optional reusable placements for PDFs generated from this template. |
name | CharField | name | No | Name of the document template. |
template | TextEditorField | template | No | Content of the template, including the variables. |
free_variables | JSONField | free_variables | No | — |
template_header | ForeignKey to bloomerp.DocumentTemplateHeader | template_header_id | Yes | Header of the document template. |
footer | TextField | footer | Yes | Footer content of the document template. |
page_orientation | CharField | page_orientation | No | Orientation of the document template. |
page_size | CharField | page_size | No | Size of the document template. |
page_margin | FloatField | page_margin | No | Margin of the document template in inches. |
include_page_numbers | BooleanField | include_page_numbers | No | Signifies whether the page numbers are included or not. |
custom_styling | CodeField | custom_styling | No | Custom CSS styling for the document template. |
content_types | ManyToManyField to contenttypes.ContentType | — | — | Root object types that can be used as variables in the document template. |
style_sets | ManyToManyField to bloomerp.DocumentTemplateStyling | — | — | Styling sets that can be applied to the document template. |
files | GenericRelation to bloomerp.FileReference | — | — | — |
comments | GenericRelation to bloomerp.Comment | — | — | — |
object_labels | BloomerpLabelsField | — | — | — |
DocumentTemplateHeader
bloomerp.models.document_templates.document_template_header.DocumentTemplateHeader
Reusable headers for document templates
Database table bloomerp_document_template_header
| Field | Type | Column | Nullable | Description |
|---|---|---|---|---|
id | UUIDField | id | No | — |
datetime_created | DateTimeField | datetime_created | No | — |
datetime_updated | DateTimeField | datetime_updated | No | — |
created_by | UserField to bloomerp.User | created_by_id | Yes | — |
updated_by | UserField to bloomerp.User | updated_by_id | Yes | — |
name | CharField | name | No | Name of the template header. |
header | ImageField | header | No | Image of the header. |
margin_top | FloatField | margin_top | No | Top margin of the header in inches. |
margin_bottom | FloatField | margin_bottom | No | Bottom margin of the header in inches. |
margin_left | FloatField | margin_left | No | Left margin of the header in inches. |
margin_right | FloatField | margin_right | No | Right margin of the header in inches. |
height | FloatField | height | No | Height of the header in inches. |
files | GenericRelation to bloomerp.FileReference | — | — | — |
comments | GenericRelation to bloomerp.Comment | — | — | — |
object_labels | BloomerpLabelsField | — | — | — |
FileNode
bloomerp.models.files.file_node.FileNode
Stored files and folders managed by Bloomerp.
Represent one folder or one immutable stored file.
A file node owns the stored bytes. A folder node organizes other nodes. Use a FileReference when an application record needs to link to a file.
Database table bloomerp_file_node
| Field | Type | Column | Nullable | Description |
|---|---|---|---|---|
id | UUIDField | id | No | — |
datetime_created | DateTimeField | datetime_created | No | — |
datetime_updated | DateTimeField | datetime_updated | No | — |
created_by | UserField to bloomerp.User | created_by_id | Yes | — |
updated_by | UserField to bloomerp.User | updated_by_id | Yes | — |
name | CharField | name | No | — |
kind | CharField | kind | No | — |
content | FileField | content | Yes | — |
parent | ForeignKey to bloomerp.FileNode | parent_id | Yes | — |
meta | JSONField | meta | No | — |
files | GenericRelation to bloomerp.FileReference | — | — | — |
comments | GenericRelation to bloomerp.Comment | — | — | — |
object_labels | BloomerpLabelsField | — | — | — |
Store a file
Usage example
Use Django's ContentFile when the content is already in memory.
from django.core.files.base import ContentFile
from bloomerp.models.files.file_node import FileNode
file = FileNode.objects.create(
name="launch-checklist.txt",
kind=FileNode.FileNodeKind.FILE,
content=ContentFile(b"Reserve the venue", name="launch-checklist.txt"),
)Move a file into a nested folder
Usage example
Use the saved file from the previous example. Create the parent folders
first, then update the file's parent. The file keeps its storage key and
existing record attachments when it moves.
from bloomerp.models.files.file_node import FileNode
projects = FileNode.objects.create(name="Projects", kind=FileNode.FileNodeKind.FOLDER)
launch = FileNode.objects.create(
name="Launch",
kind=FileNode.FileNodeKind.FOLDER,
parent=projects,
)
file.parent = launch
file.save(update_fields=["parent"])Read a file's cached metadata
Usage example
Use file.metadata to display file details without opening the stored
content. The original upload name remains available if the display name
changes. The size is in bytes and can be unknown for older files.
metadata = file.metadata
print(metadata.original_filename, metadata.mime_type, metadata.size)FileReference
bloomerp.models.files.file_reference.FileReference
Internal model
Links stored files to records, attachment fields, or rich-text placements.
Track one use of a stored file.
A file can have references from multiple records. Deleting a reference leaves the file and any other references in place.
Database table bloomerp_file_reference
| Field | Type | Column | Nullable | Description |
|---|---|---|---|---|
id | UUIDField | id | No | — |
datetime_created | DateTimeField | datetime_created | No | — |
datetime_updated | DateTimeField | datetime_updated | No | — |
created_by | UserField to bloomerp.User | created_by_id | Yes | — |
updated_by | UserField to bloomerp.User | updated_by_id | Yes | — |
file | ForeignKey to bloomerp.FileNode | file_id | No | — |
content_type | ForeignKey to contenttypes.ContentType | content_type_id | No | — |
object_id | CharField | object_id | No | — |
application_field | ForeignKey to bloomerp.ApplicationField | application_field_id | Yes | — |
occurrence_id | UUIDField | occurrence_id | Yes | — |
content_object | GenericForeignKey | — | — | — |
files | GenericRelation to bloomerp.FileReference | — | — | — |
comments | GenericRelation to bloomerp.Comment | — | — | — |
object_labels | BloomerpLabelsField | — | — | — |
Attach a stored file to a to-do
Usage example
In server-side code, pass a saved file and a saved to-do the caller can
update. create_reference() reuses the attachment if it already exists.
from bloomerp.models.files.file_node import FileNode
from bloomerp.models.files.file_reference import FileReference
from bloomerp.models.project_management.todo import Todo
def attach_file_to_todo(file: FileNode, todo: Todo) -> FileReference:
'''Link an existing stored file to a to-do.'''
return file.create_reference(todo)Share one file across two records
Usage example
Starting with a saved file, create a separate reference for each to-do.
Both references point to the same stored file.
from bloomerp.models.project_management.todo import Todo
review = Todo.objects.create(title="Review the launch checklist")
publish = Todo.objects.create(title="Publish the launch checklist")
review_attachment = file.create_reference(review)
publish_attachment = file.create_reference(publish)List a to-do's record attachments
Usage example
Use the files relation on the saved review to-do. Filtering for an
empty application_field selects attachments linked directly to the
record. Load the file nodes in the same query with select_related().
attachments = review.files.filter(application_field__isnull=True).select_related("file")
for attachment in attachments:
print(attachment.file.name)Remove one record's attachment
Usage example
Delete the reference to detach the file from the review to-do. The stored file and the publish to-do's attachment remain available.
review_attachment.delete()Page
bloomerp.models.files.page.Page
Personal and shared rich-text pages.
Store a page whose owner controls sharing and deletion.
Database table bloomerp_page
| Field | Type | Column | Nullable | Description |
|---|---|---|---|---|
id | UUIDField | id | No | — |
datetime_created | DateTimeField | datetime_created | No | — |
datetime_updated | DateTimeField | datetime_updated | No | — |
created_by | UserField to bloomerp.User | created_by_id | Yes | — |
updated_by | UserField to bloomerp.User | updated_by_id | Yes | — |
title | CharField | title | No | — |
content | TextField | content | No | — |
owner | ForeignKey to bloomerp.User | owner_id | No | — |
shared_with_users | ManyToManyField to bloomerp.User | — | — | — |
shared_with_groups | ManyToManyField to auth.Group | — | — | — |
files | GenericRelation to bloomerp.FileReference | — | — | — |
comments | GenericRelation to bloomerp.Comment | — | — | — |
object_labels | BloomerpLabelsField | — | — | — |
SignatureRecipient
bloomerp.models.document_signing.signature_recipient.SignatureRecipient
Internal model
Assign one request role to an email recipient without requiring a user account.
Database table bloomerp_signaturerecipient
| Field | Type | Column | Nullable | Description |
|---|---|---|---|---|
id | UUIDField | id | No | — |
datetime_created | DateTimeField | datetime_created | No | — |
datetime_updated | DateTimeField | datetime_updated | No | — |
created_by | UserField to bloomerp.User | created_by_id | Yes | — |
updated_by | UserField to bloomerp.User | updated_by_id | Yes | — |
request | ForeignKey to bloomerp.SignatureRequest | request_id | No | — |
role_key | SlugField | role_key | No | — |
role_label | CharField | role_label | No | — |
name | CharField | name | No | — |
email | EmailField | email | No | — |
user | ForeignKey to bloomerp.User | user_id | Yes | — |
signing_order | PositiveIntegerField | signing_order | No | — |
status | CharField | status | No | — |
consent_text | TextField | consent_text | No | — |
consented_at | DateTimeField | consented_at | Yes | — |
signed_at | DateTimeField | signed_at | Yes | — |
declined_at | DateTimeField | declined_at | Yes | — |
decline_reason | TextField | decline_reason | No | — |
email_delivery | JSONField | email_delivery | No | — |
files | GenericRelation to bloomerp.FileReference | — | — | — |
comments | GenericRelation to bloomerp.Comment | — | — | — |
object_labels | BloomerpLabelsField | — | — | — |
SignatureRequest
bloomerp.models.document_signing.signature_request.SignatureRequest
A request for one or multiple parties to sign a PDF document.
Retain a PDF, recipient snapshots, and its completed output without domain ties.
Database table bloomerp_signaturerequest
| Field | Type | Column | Nullable | Description |
|---|---|---|---|---|
id | UUIDField | id | No | — |
datetime_created | DateTimeField | datetime_created | No | — |
datetime_updated | DateTimeField | datetime_updated | No | — |
created_by | UserField to bloomerp.User | created_by_id | Yes | — |
updated_by | UserField to bloomerp.User | updated_by_id | Yes | — |
title | CharField | title | No | — |
email_account | ForeignKey to bloomerp.EmailAccount | email_account_id | Yes | — |
email_content | TextField | email_content | No | — |
status | CharField | status | No | — |
signature_level | CharField | signature_level | No | — |
source_layout | ForeignKey to bloomerp.SignatureLayout | source_layout_id | Yes | — |
source_layout_name | CharField | source_layout_name | No | — |
source_layout_revision | PositiveIntegerField | source_layout_revision | Yes | — |
source_preparation | ForeignKey to bloomerp.SignaturePreparation | source_preparation_id | Yes | — |
source_preparation_revision | PositiveIntegerField | source_preparation_revision | Yes | — |
original_file | ForeignKey to bloomerp.FileNode | original_file_id | No | — |
original_sha256 | CharField | original_sha256 | No | — |
signed_file | ForeignKey to bloomerp.FileNode | signed_file_id | Yes | — |
signed_sha256 | CharField | signed_sha256 | No | — |
sent_at | DateTimeField | sent_at | Yes | — |
expires_at | DateTimeField | expires_at | Yes | — |
completed_at | DateTimeField | completed_at | Yes | — |
files | GenericRelation to bloomerp.FileReference | — | — | — |
comments | GenericRelation to bloomerp.Comment | — | — | — |
object_labels | BloomerpLabelsField | — | — | — |
SignatureRequestField
bloomerp.models.document_signing.signature_request_field.SignatureRequestField
Internal model
Retain a concrete placement independently of subsequent reusable layout edits.
Database table bloomerp_signaturerequestfield
| Field | Type | Column | Nullable | Description |
|---|---|---|---|---|
id | UUIDField | id | No | — |
datetime_created | DateTimeField | datetime_created | No | — |
datetime_updated | DateTimeField | datetime_updated | No | — |
created_by | UserField to bloomerp.User | created_by_id | Yes | — |
updated_by | UserField to bloomerp.User | updated_by_id | Yes | — |
key | SlugField | key | No | — |
field_type | CharField | field_type | No | — |
required | BooleanField | required | No | — |
page_number | PositiveIntegerField | page_number | No | — |
x | DecimalField | x | No | — |
y | DecimalField | y | No | — |
width | DecimalField | width | No | — |
height | DecimalField | height | No | — |
settings | JSONField | settings | No | — |
request | ForeignKey to bloomerp.SignatureRequest | request_id | No | — |
recipient | ForeignKey to bloomerp.SignatureRecipient | recipient_id | No | — |
value | JSONField | value | Yes | — |
filled_at | DateTimeField | filled_at | Yes | — |
files | GenericRelation to bloomerp.FileReference | — | — | — |
comments | GenericRelation to bloomerp.Comment | — | — | — |
object_labels | BloomerpLabelsField | — | — | — |
