BloomERP

File Management models

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

FieldTypeColumnNullableDescription
idUUIDFieldidNo—
datetime_createdDateTimeFielddatetime_createdNo—
datetime_updatedDateTimeFielddatetime_updatedNo—
created_byUserField to bloomerp.Usercreated_by_idYes—
updated_byUserField to bloomerp.Userupdated_by_idYes—
default_signature_layoutForeignKey to bloomerp.SignatureLayoutdefault_signature_layout_idYesOptional reusable placements for PDFs generated from this template.
nameCharFieldnameNoName of the document template.
templateTextEditorFieldtemplateNoContent of the template, including the variables.
free_variablesJSONFieldfree_variablesNo—
template_headerForeignKey to bloomerp.DocumentTemplateHeadertemplate_header_idYesHeader of the document template.
footerTextFieldfooterYesFooter content of the document template.
page_orientationCharFieldpage_orientationNoOrientation of the document template.
page_sizeCharFieldpage_sizeNoSize of the document template.
page_marginFloatFieldpage_marginNoMargin of the document template in inches.
include_page_numbersBooleanFieldinclude_page_numbersNoSignifies whether the page numbers are included or not.
custom_stylingCodeFieldcustom_stylingNoCustom CSS styling for the document template.
content_typesManyToManyField to contenttypes.ContentType——Root object types that can be used as variables in the document template.
style_setsManyToManyField to bloomerp.DocumentTemplateStyling——Styling sets that can be applied to the document template.
filesGenericRelation to bloomerp.FileReference———
commentsGenericRelation to bloomerp.Comment———
object_labelsBloomerpLabelsField———

DocumentTemplateHeader

bloomerp.models.document_templates.document_template_header.DocumentTemplateHeader

Reusable headers for document templates

Database table bloomerp_document_template_header

FieldTypeColumnNullableDescription
idUUIDFieldidNo—
datetime_createdDateTimeFielddatetime_createdNo—
datetime_updatedDateTimeFielddatetime_updatedNo—
created_byUserField to bloomerp.Usercreated_by_idYes—
updated_byUserField to bloomerp.Userupdated_by_idYes—
nameCharFieldnameNoName of the template header.
headerImageFieldheaderNoImage of the header.
margin_topFloatFieldmargin_topNoTop margin of the header in inches.
margin_bottomFloatFieldmargin_bottomNoBottom margin of the header in inches.
margin_leftFloatFieldmargin_leftNoLeft margin of the header in inches.
margin_rightFloatFieldmargin_rightNoRight margin of the header in inches.
heightFloatFieldheightNoHeight of the header in inches.
filesGenericRelation to bloomerp.FileReference———
commentsGenericRelation to bloomerp.Comment———
object_labelsBloomerpLabelsField———

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

FieldTypeColumnNullableDescription
idUUIDFieldidNo—
datetime_createdDateTimeFielddatetime_createdNo—
datetime_updatedDateTimeFielddatetime_updatedNo—
created_byUserField to bloomerp.Usercreated_by_idYes—
updated_byUserField to bloomerp.Userupdated_by_idYes—
nameCharFieldnameNo—
kindCharFieldkindNo—
contentFileFieldcontentYes—
parentForeignKey to bloomerp.FileNodeparent_idYes—
metaJSONFieldmetaNo—
filesGenericRelation to bloomerp.FileReference———
commentsGenericRelation to bloomerp.Comment———
object_labelsBloomerpLabelsField———

Store a file

Usage example

Use Django's ContentFile when the content is already in memory.

python
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.

python
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.

python
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

FieldTypeColumnNullableDescription
idUUIDFieldidNo—
datetime_createdDateTimeFielddatetime_createdNo—
datetime_updatedDateTimeFielddatetime_updatedNo—
created_byUserField to bloomerp.Usercreated_by_idYes—
updated_byUserField to bloomerp.Userupdated_by_idYes—
fileForeignKey to bloomerp.FileNodefile_idNo—
content_typeForeignKey to contenttypes.ContentTypecontent_type_idNo—
object_idCharFieldobject_idNo—
application_fieldForeignKey to bloomerp.ApplicationFieldapplication_field_idYes—
occurrence_idUUIDFieldoccurrence_idYes—
content_objectGenericForeignKey———
filesGenericRelation to bloomerp.FileReference———
commentsGenericRelation to bloomerp.Comment———
object_labelsBloomerpLabelsField———

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.

python
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.

python
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().

python
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.

python
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

FieldTypeColumnNullableDescription
idUUIDFieldidNo—
datetime_createdDateTimeFielddatetime_createdNo—
datetime_updatedDateTimeFielddatetime_updatedNo—
created_byUserField to bloomerp.Usercreated_by_idYes—
updated_byUserField to bloomerp.Userupdated_by_idYes—
titleCharFieldtitleNo—
contentTextFieldcontentNo—
ownerForeignKey to bloomerp.Userowner_idNo—
shared_with_usersManyToManyField to bloomerp.User———
shared_with_groupsManyToManyField to auth.Group———
filesGenericRelation to bloomerp.FileReference———
commentsGenericRelation to bloomerp.Comment———
object_labelsBloomerpLabelsField———

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

FieldTypeColumnNullableDescription
idUUIDFieldidNo—
datetime_createdDateTimeFielddatetime_createdNo—
datetime_updatedDateTimeFielddatetime_updatedNo—
created_byUserField to bloomerp.Usercreated_by_idYes—
updated_byUserField to bloomerp.Userupdated_by_idYes—
requestForeignKey to bloomerp.SignatureRequestrequest_idNo—
role_keySlugFieldrole_keyNo—
role_labelCharFieldrole_labelNo—
nameCharFieldnameNo—
emailEmailFieldemailNo—
userForeignKey to bloomerp.Useruser_idYes—
signing_orderPositiveIntegerFieldsigning_orderNo—
statusCharFieldstatusNo—
consent_textTextFieldconsent_textNo—
consented_atDateTimeFieldconsented_atYes—
signed_atDateTimeFieldsigned_atYes—
declined_atDateTimeFielddeclined_atYes—
decline_reasonTextFielddecline_reasonNo—
email_deliveryJSONFieldemail_deliveryNo—
filesGenericRelation to bloomerp.FileReference———
commentsGenericRelation to bloomerp.Comment———
object_labelsBloomerpLabelsField———

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

FieldTypeColumnNullableDescription
idUUIDFieldidNo—
datetime_createdDateTimeFielddatetime_createdNo—
datetime_updatedDateTimeFielddatetime_updatedNo—
created_byUserField to bloomerp.Usercreated_by_idYes—
updated_byUserField to bloomerp.Userupdated_by_idYes—
titleCharFieldtitleNo—
email_accountForeignKey to bloomerp.EmailAccountemail_account_idYes—
email_contentTextFieldemail_contentNo—
statusCharFieldstatusNo—
signature_levelCharFieldsignature_levelNo—
source_layoutForeignKey to bloomerp.SignatureLayoutsource_layout_idYes—
source_layout_nameCharFieldsource_layout_nameNo—
source_layout_revisionPositiveIntegerFieldsource_layout_revisionYes—
source_preparationForeignKey to bloomerp.SignaturePreparationsource_preparation_idYes—
source_preparation_revisionPositiveIntegerFieldsource_preparation_revisionYes—
original_fileForeignKey to bloomerp.FileNodeoriginal_file_idNo—
original_sha256CharFieldoriginal_sha256No—
signed_fileForeignKey to bloomerp.FileNodesigned_file_idYes—
signed_sha256CharFieldsigned_sha256No—
sent_atDateTimeFieldsent_atYes—
expires_atDateTimeFieldexpires_atYes—
completed_atDateTimeFieldcompleted_atYes—
filesGenericRelation to bloomerp.FileReference———
commentsGenericRelation to bloomerp.Comment———
object_labelsBloomerpLabelsField———

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

FieldTypeColumnNullableDescription
idUUIDFieldidNo—
datetime_createdDateTimeFielddatetime_createdNo—
datetime_updatedDateTimeFielddatetime_updatedNo—
created_byUserField to bloomerp.Usercreated_by_idYes—
updated_byUserField to bloomerp.Userupdated_by_idYes—
keySlugFieldkeyNo—
field_typeCharFieldfield_typeNo—
requiredBooleanFieldrequiredNo—
page_numberPositiveIntegerFieldpage_numberNo—
xDecimalFieldxNo—
yDecimalFieldyNo—
widthDecimalFieldwidthNo—
heightDecimalFieldheightNo—
settingsJSONFieldsettingsNo—
requestForeignKey to bloomerp.SignatureRequestrequest_idNo—
recipientForeignKey to bloomerp.SignatureRecipientrecipient_idNo—
valueJSONFieldvalueYes—
filled_atDateTimeFieldfilled_atYes—
filesGenericRelation to bloomerp.FileReference———
commentsGenericRelation to bloomerp.Comment———
object_labelsBloomerpLabelsField———