Skip to content

Centurion Abstract Sub-Model


This abstract model establishes the base features for ALL sub-models within Centurion ERP

Bases: CenturionModel

Attributes

app_namespace

app_namespace: str = None

URL Application namespace.

Note: This attribute is a temp attribute until all models urls return to their own urls.py file from api/urls_v2.py.

created

created = AutoCreatedField(editable=True)

id

id = AutoField(blank=False, help_text='ID of the item', primary_key=True, unique=True, verbose_name='ID')

model_notes

model_notes = TextField(blank=True, help_text='Tid bits of information', null=True, verbose_name='Notes')

model_tag

model_tag: str = None

Model Tag

String that is used as this models tag. Used within ticketing for linking a model to a ticket and wihin markdown for referencing a model.

url_model_name

url_model_name: str = None

URL Model Name override

Optionally use this attribute to set the model name for the url basename, i.e. _api_<url_model_name>

Classes

Meta

Attributes

abstract
abstract = True

Functions

delete

delete(using=None, keep_parents=None)

Delete Centurion Model

If a model has _audit_enabled = True, audit history is populated and ready to be saved by the audit system (save signal.).

Parameters:

Name Type Description Default
using _type_

description. Defaults to None.

None
keep_parents bool

Keep parent models. Defaults to the value if is_submodel so as not to delete parent models.

None

full_clean

full_clean(exclude=None, validate_unique=True, validate_constraints=True) -> None

get_after

get_after() -> dict

Audit Data After Change

Returns:

Name Type Description
dict dict

All model fields after the data changed

get_app_namespace

get_app_namespace() -> str

Fetch the Application namespace if specified.

Note: This attribute is a temp attribute until all models urls return to their own urls.py file from api/urls_v2.py.

Returns:

Name Type Description
str str

Application namespace suffixed with colin :

None str

No application namespace found.

get_audit_values

get_audit_values() -> dict

Retrieve the field Values

Currently ensures only fields are present.

ToDo: Update so the dict that it returns is a dict of dict where each dict is named after the actual models the fields come from and it contains only it's fields.

Returns:

Name Type Description
dict dict

Model fields

get_before

get_before() -> dict

Audit Data Before Change

Returns:

Name Type Description
dict dict

All model fields before the data changed

get_history_model_name

get_history_model_name() -> str

Get the name for the History Model

Returns:

Name Type Description
str str

Name of the history model (<model class name>AuditHistory)

get_url

get_url(relative: bool = False, api_version: int = 2, many=False, request: any = None) -> str

Return the models API URL

Parameters:

Name Type Description Default
relative bool

Return the relative URL for the model. Defaults to False.

False
api_version int

API Version to use. Defaults to `2``.

2
request any

Temp and unused attribute until rest of codebase re-written not to pass through.

None

Returns:

Name Type Description
str str

API URL for the model

get_url_kwargs

get_url_kwargs(many=False)

save

save(force_insert=False, force_update=False, using=None, update_fields=None)

Save Centurion Model

This Save ensures that full_clean() is called so that prior to the model being saved to the database, it is valid.

If a model has _audit_enabled = True, audit history is populated and ready to be saved by the audit system (save signal.).

validate_field_not_none

validate_field_not_none(value)

About:

This page forms part of our Project Centurion ERP.

Page Metadata
Version: ToDo: place files short git commit here
Date Created: 2025-05-25
Date Edited: 2025-05-24

Contribution:

Would You like to contribute to our Centurion ERP project? You can assist in the following ways:

 

ToDo: Add the page list of contributors