Skip to content

Models


Models within Centurion ERP are how the data is structured within the database. This page contains documentation pertinent to the development of the models for use with Centurion ERP.

All models within Centurion ERP are what we call a "Tenancy Object." A tenancy object is a model that takes advantage of the multi-tenancy features of Centurion ERP.

Requirements

All models must meet the following requirements:

  • inherits from app.access.models.TenancyObject

    Tip

    There is no requirement to include class app.core.mixin.history_save.SaveHistory for inheritence as this class is already included within class app.access.models.TenancyObject.

    Note

    If there is a specific use case for the object not to be a tenancy object, this will need to be discussed with a maintainer.

  • class has __str__ method defined to return that is used to return a default value if no field is specified.

  • Fields are initialized with the following parameters:

    • verbose_name

    • help_text

  • No queryset is to return data that the user has not got access to. see queryset()

  • Single Field validation is conducted if required.

    Requirement

    Multi-field validation, or validation that requires access to multiple fields must be done within the form class.

  • contains a Meta sub-class with following parameters:

    • verbose_name_plural
  • If creating a new model, function access.functions.permissions.permission_queryset() has been updated to display the models permission(s)

History

Currently the adding of history to a model is a manual process. edit the file located at core.views.history and within View.get_object add the model to the switch statement.

Tests

The following Unit test cases exists for models:

Info

If you add a feature you will have to write the test cases for that feature if they are not covered by existing test cases.

Docs to clean up

Note

The below documentation is still to be developed. As such what is written below may be incorrect.

for items that have a parent item, modification will need to be made to the mixin by adding the relevant check and setting the relevant keys.

if self._meta.model_name == 'deviceoperatingsystem':

    item_parent_pk = self.device.pk
    item_parent_class = self.device._meta.model_name

About:

This page forms part of our Project Centurion ERP.

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

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