Skip to content

Centurion Tenancy Abstract Model


This abstract model establishes the tenancy features for ALL models within Centurion ERP

Bases: Model

Tenancy Model Abstract class.

This class is for inclusion within every model within Centurion ERP. Provides the required fields, functions and methods for multi tennant objects. Unless otherwise stated, no object within this class may be overridden.

Raises:

Type Description
ValidationError

User failed to supply organization

Attributes

context

context: dict = {'logger': None, 'user': None}

Model Context

Generally model usage will be from an API serializer, Admin Site or a management command. These sources are to pass through and set this context. The keys are:

Warning

Failing to specify the user will prevent the tenancy manager from being multi-tenant. As such, the results retured will not be restricted to the users tenancy

Returns:

Name Type Description
logger Logger

Instance of a logger for logging.

user User

The user that is logged into the system

Context for actions within the model.

objects

objects = TenancyManager()

~~Multi-Tenant Manager~~

Note: ~~This manager relies upon the model class having context['user'] set. without a user the manager can not perform multi-tenant queries.~~

organization

organization = ForeignKey(Tenant, blank=False, help_text='Tenant this belongs to', null=False, on_delete=CASCADE, related_name='+', validators=[validatate_organization_exists], verbose_name='Tenant')

Classes

Meta

Attributes

abstract
abstract = True

Functions

get_tenant

get_tenant() -> Tenant

Return the models Tenancy

This model can be safely over-ridden as long as it returns the models tenancy

validatate_organization_exists

validatate_organization_exists()

Ensure that the user did provide an organization

Raises:

Type Description
ValidationError

User failed to supply organization.

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