|
| 1 | +--- |
| 2 | +review-status: needs-review |
| 3 | +review-date: 2025-08-22 |
| 4 | +reviewer: migration-script |
| 5 | +migration-notes: "Added during 2025 documentation reorganization" |
| 6 | +--- |
| 7 | + |
| 8 | +# Customize Document Management System |
| 9 | + |
| 10 | +## Introduction |
| 11 | + |
| 12 | +The OpenSPP Document Management System (DMS), provided by the `spp_dms` module, is a robust system for organizing and managing files. It allows for a structured repository of documents related to social protection programs, using a hierarchy of directories, files, and categories. |
| 13 | + |
| 14 | +**Document Categories** are a key feature of the DMS, allowing users to classify files for streamlined searching, filtering, and reporting. This guide will walk you through the simple process of extending the DMS by adding new, custom document categories. We will create a small module that adds a "Proof of School Enrollment" category, which can then be used to classify documents across the platform. |
| 15 | + |
| 16 | +By the end of this guide, you will be able to: |
| 17 | + |
| 18 | +- Understand how to add new DMS categories. |
| 19 | +- Create a simple data module to extend DMS functionality. |
| 20 | +- Register the new categories so they are available system-wide. |
| 21 | + |
| 22 | +## Prerequisites |
| 23 | + |
| 24 | +- Basic understanding of Odoo 17 module development. |
| 25 | +- Knowledge of XML for creating data files. |
| 26 | +- Familiarity with the `spp_dms` core module. |
| 27 | +- To set up OpenSPP for development, please refer to the [Developer Guide](https://docs.openspp.org/howto/developer_guides/development_setup.html) |
| 28 | + |
| 29 | +## Module Structure |
| 30 | + |
| 31 | +A module for adding new DMS categories is very simple and typically only contains data files. Here's the complete structure of the module we will build, `spp_dms_school_documents`: |
| 32 | + |
| 33 | +``` |
| 34 | +spp_dms_school_documents/ |
| 35 | +├── __init__.py |
| 36 | +├── __manifest__.py |
| 37 | +└── data/ |
| 38 | + └── dms_category_data.xml |
| 39 | +``` |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## Step-by-Step Guide |
| 44 | + |
| 45 | +### Step 1: Create the Module Scaffold |
| 46 | + |
| 47 | +Begin by creating a new directory for your module (e.g., `spp_dms_school_documents`) and add the basic Odoo module files: `__init__.py` and `__manifest__.py`. Then, create the `data` subdirectory. |
| 48 | + |
| 49 | +### Step 2: Define the Manifest (`__manifest__.py`) |
| 50 | + |
| 51 | +The manifest file declares your module's metadata and its dependencies. Our module only needs to depend on `spp_dms` to get access to the `spp.dms.category` model. |
| 52 | + |
| 53 | +```python |
| 54 | +# From: spp_dms_school_documents/__manifest__.py |
| 55 | +{ |
| 56 | + "name": "OpenSPP DMS School Documents", |
| 57 | + "summary": "Adds custom DMS categories for school-related documents.", |
| 58 | + "category": "OpenSPP", |
| 59 | + "version": "17.0.1.0.0", |
| 60 | + "author": "OpenSPP.org", |
| 61 | + "website": "https://github.com/OpenSPP/openspp-modules", |
| 62 | + "license": "LGPL-3", |
| 63 | + "depends": [ |
| 64 | + "spp_dms", |
| 65 | + ], |
| 66 | + "data": [ |
| 67 | + "data/dms_category_data.xml", |
| 68 | + ], |
| 69 | + "installable": True, |
| 70 | + "auto_install": False, |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +### Step 3: Create the Data File |
| 75 | + |
| 76 | +This is where you define the new document categories. In the `data/` directory, create an XML file named `dms_category_data.xml`. |
| 77 | + |
| 78 | +This file will contain one or more `<record>` tags that create new entries in the `spp.dms.category` model. Each record needs a unique ID and the name of the new category. |
| 79 | + |
| 80 | +```xml |
| 81 | +<!-- From: spp_dms_school_documents/data/dms_category_data.xml --> |
| 82 | +<?xml version="1.0" encoding="utf-8" ?> |
| 83 | +<odoo> |
| 84 | + <data noupdate="1"> |
| 85 | + |
| 86 | + <record id="spp_dms_school_enrollment" model="spp.dms.category"> |
| 87 | + <field name="name">Proof of School Enrollment</field> |
| 88 | + </record> |
| 89 | + |
| 90 | + <record id="spp_dms_report_card" model="spp.dms.category"> |
| 91 | + <field name="name">School Report Card</field> |
| 92 | + </record> |
| 93 | + |
| 94 | + </data> |
| 95 | +</odoo> |
| 96 | +``` |
| 97 | +The `noupdate="1"` attribute prevents the data from being overwritten if the module is updated, which is standard practice for configuration data that users might modify. |
| 98 | + |
| 99 | +### Step 4: Install and Use Your New Categories |
| 100 | + |
| 101 | +1. Start your Odoo server and update the apps list. |
| 102 | +2. Install your new module (`spp_dms_school_documents`). |
| 103 | +3. To verify that the new categories have been added, navigate to **DMS -> Configuration -> Categories**. You should see "Proof of School Enrollment" and "School Report Card" in the list. |
| 104 | +4. Now, when you upload a new file anywhere in the DMS, these new categories will be available in the **Category** dropdown menu, allowing you to classify your documents appropriately. |
| 105 | + |
| 106 | +## Conclusion |
| 107 | + |
| 108 | +You have successfully created a simple module to customize the OpenSPP Document Management System. By adding new `spp.dms.category` records, you can easily tailor the DMS to fit the specific documentation needs of any social protection program. This data-driven approach is a core strength of the Odoo framework, allowing for powerful customizations with minimal code. |
0 commit comments