Skip to content

Tenancy Object


This page contains the Tenancy Object API Documentation.

Tenancy Object Model Abstract class

Bases: SaveHistory

Tenancy Model Abstrct class.

This class is for inclusion wihtin 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

objects = TenancyManager()

Multi-Tenanant Objects

organization = models.ForeignKey(Organization, on_delete=models.CASCADE, blank=False, null=True, validators=[validatate_organization_exists])

is_global = models.BooleanField(default=False, blank=False)

model_notes = models.TextField(blank=True, default=None, null=True, verbose_name='Notes')

Classes

Meta

Attributes
abstract = True

Functions

validatate_organization_exists()

Ensure that the user did provide an organization

Raises:

Type Description
ValidationError

User failed to supply organization.

get_organization()

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

Tenancy Object Manager

Bases: Manager

Multi-Tennant Object Manager

This manager specifically caters for the multi-tenancy features of Centurion ERP.

Functions

get_queryset()

Fetch the data

This function filters the data fetched from the database to that which is from the organizations the user is a part of.

Requirement

This method may be overridden however must still be called from the overriding function. i.e. super().get_queryset()

Workflow

This functions workflow is as follows:

  • Fetch the user from the request

  • Check if the user is authenticated

  • Iterate over the users teams

  • Store unique organizations from users teams

  • return results

Returns:

Type Description
queryset

super user: return unfiltered data.

queryset

not super user: return data from the stored unique organizations.

About:

This page forms part of our Project Centurion ERP.

Page Metadata
Version: ToDo: place files short git commit here
Date Created: 2024-07-15
Date Edited: 2024-07-15

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