BloomERP

Built-ins

ObjectActionDefinition

Describe an action for a record on its detail page or in a dataview.

Callbacks receive the request, model, content type, and accessible record in ObjectActionContext. For a row action, context.dataview also contains the originating dataview. Register the definition using its ID as the key.

SettingTypeDefaultDescription
idstrRequiredStable ID used in action configuration.Minimum length: 1
documentationstr''Markdown and tagged examples included in the generated developer reference.
modelsModelSelector'__all__'Model scope. Use a Django model class, a list of classes, 'all', or a zero-argument callable returning one of those selectors. Use None or an empty list for no models.
methodstuple[Literal['GET', 'POST'], ...]('GET', 'POST')Allowed HTTP methods. The first is used by the action button.Minimum length: 1
methodOptional[Literal['GET', 'POST']]NoneLegacy single-method override for existing action definitions.
descriptionstr''The description of the action.
labelstr | NoneNoneOptional label for the action.
iconstr | NoneNoneOptional Font Awesome icon for the action.
shortcutstr | NoneNoneOptional keyboard shortcut, such as 'alt+arrowright' (Alt + Right Arrow), or a sequence like 'k then p'.
get_button_attrsCallable[[ObjectActionContext], dict[str, Any]]BaseActionDefinition.<lambda>Return additional HTML attributes for the default action button.
get_query_paramsCallable[[ObjectActionContext], ActionQueryParams] | NoneNoneReturn query parameters for the default action button's URL. A sequence gives repeated values. Object actions add no extra parameters by default. Dataview HTMX actions use live filters and selection by default. For a custom HTMX URL, supply a callback to use its own query parameters, or return an empty mapping to leave the URL as supplied. Registered action handlers still receive their source dataview context.
is_visibleCallable[[ObjectActionContext], bool]BaseActionDefinition.<lambda>Determine whether to show the action in the current context.
executeCallable[[ObjectActionContext], HttpResponse | StreamingHttpResponse | None] | NoneNoneHandler for an action request. HTML-only controls can omit it.
success_messagestr | NoneNoneMessage shown when the handler returns no response.
refresh_on_successOptional[Literal['item', 'dataview']]NoneRefresh the originating record or dataview when the handler returns no response.
renderCallable[[ObjectActionContext, Mapping[str, Any]], str] | NoneNoneReturn an HTML fragment using the action context and surrounding template context. The template context includes the current definition under 'action'.

Show the record ID

Add example-show-record-id to a model's object action list.

python
from django.http import HttpResponse

from bloomerp.actions import OBJECT_ACTION_REGISTRY
from bloomerp.actions.definition import ObjectActionContext, ObjectActionDefinition
from bloomerp.utils.requests import render_message


def show_record_id(context: ObjectActionContext) -> HttpResponse:
    '''Show the primary key of the current record.'''
    return render_message(context.request, f"Record ID: {context.object.pk}", "info")


show_id = ObjectActionDefinition(
    id="example-show-record-id",
    label="Show record ID",
    description="Display the primary key of the current record.",
    execute=show_record_id,
)
OBJECT_ACTION_REGISTRY.register(show_id.id, show_id)

Open a workspace in a new tab

Set models to the model that supplies the destination URL.

python
from bloomerp.actions import OBJECT_ACTION_REGISTRY
from bloomerp.actions.definition import ObjectActionContext, ObjectActionDefinition
from bloomerp.models.workspaces import Workspace


def workspace_link(context: ObjectActionContext) -> dict[str, str]:
    '''Return the attributes for an ordinary link to the workspace.'''
    return {"href": context.object.get_absolute_url(), "target": "_blank", "rel": "noopener"}


open_workspace = ObjectActionDefinition(
    id="example-open-workspace-tab",
    label="Open in new tab",
    description="Open this workspace in a new browser tab.",
    models=Workspace,
    get_button_attrs=workspace_link,
)
OBJECT_ACTION_REGISTRY.register(open_workspace.id, open_workspace)

Activity

ID activity

Show changes recorded for this record in its detail sidebar.

Models All models

FieldValue
iconfa fa-history
shortcutd then a

Comments

ID comments

Open the conversation attached to this record in its detail sidebar.

Models All models

FieldValue
iconfa fa-comments
shortcutd then m

Create Todo

ID create-todo

Open a Todo form with the current record as its linked object.

Models All models

FieldValue
iconfa fa-list-check
shortcutd then t

Contact

ID contact

Show available communication options for readable contact fields.

Models All models

FieldValue
iconfa fa-address-book
shortcutd then c

workflow-actions

ID workflow-actions

Show eligible workflows for the selected record.

Models All models

Execute

ID execute_sql_query

Execute the saved SQL query and show its results.

Models bloomerp.sqlquery

FieldValue
methodGET
iconfa-solid fa-play

Open workspace

ID open-workspace

Open the selected workspace in the main content area.

Models bloomerp.workspace

Revoke API Key

ID revoke_api_key

Revoke an active API key and refresh the current page.

Models bloomerp.apikey

FieldValue
methodPOST
iconfa fa-solid fa-xmark

View

ID view_file

Preview the file in the shared drawer.

Models bloomerp.filenode

Email

ID email

Open the email composer with the file attached.

Models bloomerp.filenode

Rename

ID rename_file

Open the form for changing the file's display name.

Models bloomerp.filenode

Move

ID move_file

Open the form for moving the file to another folder.

Models bloomerp.filenode

Delete

ID delete_file

Open the confirmation for deleting an unused file.

Models bloomerp.filenode

Sign

ID sign_file

Open the signing wizard for this PDF.

Models bloomerp.filenode

Generate document

ID generate-document

Open generation with the embedding record selected.

Models bloomerp.documenttemplate

FieldValue
iconfa-solid fa-file

Assign

ID assign

Open the form for assigning recipients to the signature request.

Models bloomerp.signaturerequest

FieldValue
iconfa-solid fa-user-plus

Send

ID send

Open the form for sending the signature request to its recipients.

Models bloomerp.signaturerequest

FieldValue
iconfa-regular fa-paper-plane

ID signing_links

Show links for authorized recipients to sign the document.

Models bloomerp.signaturerequest

Sign

ID sign

Open the signing form for the current recipient.

Models bloomerp.signaturerequest

FieldValue
iconfa-solid fa-signature

ID form_links

Show the available links for this form.

Models bloomerp.form

public_embed

ID public_embed

Show the embed code for a form that allows embedding.

Models bloomerp.form

Persist

ID persist

Persist the data from the reviewed form submission.

Models bloomerp.formsubmission

FieldValue
methodPOST

Synchronize phone numbers

ID synchronize_numbers

Synchronize phone numbers from this connection's carrier.

Models bloomerp.voipconnection

FieldValue
methodPOST
iconfa-solid fa-rotate

ID share_booking_link

Copy the public booking URL for this record to the clipboard.

Models bloomerp.bookinglink

FieldValue
iconfa-solid fa-link

Approve booking

ID approve_booking

Approve a pending booking and refresh its row.

Models bloomerp.bookinglinksubmission

FieldValue
methodPOST
iconfa-solid fa-check

Reply to invitation

ID reply_invitation

Open the attendance form for the invited participant.

Models bloomerp.calendarevent

Run workflow

ID run_workflow

Open the form to run the selected workflow.

Models bloomerp.workflow

Approve

ID approve_step

Open the continuation approval form for a paused workflow run.

Models bloomerp.workflowrun

Edit

ID edit-revision

Open this tutorial revision in the editor.

Models bloomerp.tutorialrevision

FieldValue
iconfa-solid fa-pen

Publish

ID publish-revision

Publish the selected tutorial revision.

Models bloomerp.tutorialrevision

FieldValue
methodPOST
iconfa-solid fa-upload

Start tutorial

ID start-tutorial

Start the published walkthrough for this tutorial.

Models bloomerp.tutorial

FieldValue
iconfa-solid fa-play

Create revision

ID create-revision

Open the form to create a new revision of this tutorial.

Models bloomerp.tutorial

FieldValue
iconfa-solid fa-plus

Revisions

ID revisions

Open the dataview of revisions belonging to this tutorial.

Models bloomerp.tutorial

FieldValue
iconfa-solid fa-list