How to Integrate a Custom Module into Dolibarr?
   03/06/2025 00:00:00     Dolibarr    0 Comments
How to Integrate a Custom Module into Dolibarr?

Dolibarr is an open-source ERP and CRM solution known for its flexibility and modularity. Thanks to its architecture, users can add specific functionalities by developing custom modules. Whether to address specific business needs, automate tasks, or enhance the user experience, integrating a custom module into Dolibarr is an ideal solution.

In this article, we will explore step by step how to integrate a custom module into Dolibarr, from its design to its installation, development, and configuration.


1. Why Create a Custom Module for Dolibarr?

Dolibarr offers a wide range of built-in modules and extensions available on Dolistore. However, sometimes these solutions do not fully meet a company's specific requirements. Here are some reasons to create a custom module:

  • Automate internal processes specific to your business.
  • Add new functionalities not available in Dolibarr or existing modules.
  • Modify or improve the user interface to enhance usability.
  • Create connectors with other applications used within the company.
  • Customize reports and dashboards for more tailored insights.

2. Prerequisites Before Integrating a Custom Module

Before starting the integration, ensure that your Dolibarr environment is ready to accept a new module.

2.1 Check Your Dolibarr Version

Each module must be compatible with your installed Dolibarr version. To check your version:

  1. Log in to Dolibarr as an administrator.
  2. Navigate to Home → Setup → System Information.

Ensure your module is compatible with this version.

2.2 Enable Developer Mode

Dolibarr has a developer mode that helps display errors and facilitates debugging:

  1. Go to Setup → Miscellaneous.
  2. Add the following line to the conf/conf.php file:
    php
    $dolibarr_main_prod = 0;

2.3 Access the Module Directory

All Dolibarr modules are stored in the following directory:

bash
htdocs/custom/

It is recommended to create your own modules in this directory to prevent overwriting core files during updates.


3. Developing a Custom Module for Dolibarr

A Dolibarr module mainly consists of PHP files and specific structures.

3.1 Creating the Module Structure

A Dolibarr module is organized as follows:

bash
htdocs/custom/mymodule/ │── core/ │ ├── modules/ │── class/ │── admin/ │── script/ │── mymodule.php │── README.md │── modulebuilder.json

Explanation of directories:

  • core/modules/: Contains module configuration files.
  • class/: Defines the PHP classes used by the module.
  • admin/: Administration interface for the module.
  • script/: Additional scripts for installation or updates.

3.2 Creating the Module Configuration File

The main module file (mymodule.php) allows Dolibarr to recognize the module:

php
class modMymodule extends DolibarrModules { function __construct($db) { global $langs; $this->db = $db; $this->numero = 500000; $this->family = "custom"; $this->name = "Mymodule"; $this->description = "A custom module for Dolibarr"; $this->version = "1.0"; $this->rights_class = 'mymodule'; } }

3.3 Adding an SQL Table to Store Data

If your module needs to store specific information, create an SQL table:

sql
CREATE TABLE llx_mymodule ( rowid INT AUTO_INCREMENT PRIMARY KEY, label VARCHAR(255) NOT NULL, date_creation TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB;

The SQL script can be placed in script/install.sql and executed upon module activation.


4. Installing and Activating the Module in Dolibarr

Once your module is developed, it must be integrated into Dolibarr.

4.1 Copying the Module into Dolibarr

Place your module folder in:

bash
htdocs/custom/

4.2 Activating the Module from the Administration Panel

  1. Navigate to Setup → Modules/Applications.
  2. Search for your module in the list.
  3. Click Activate.
  4. If necessary, run any associated SQL scripts.

5. Testing and Debugging Your Module

5.1 Checking Error Logs

If your module does not function properly, check Dolibarr’s error logs in:

bash
htdocs/documents/dolibarr.log

5.2 Enabling PHP Debug Mode

Add this line to conf/conf.php to display errors:

php
ini_set('display_errors', 1); error_reporting(E_ALL);

5.3 Conducting User Testing

  • Verify if permissions work correctly.
  • Test the module's interface and forms.
  • Ensure compatibility with other active modules.

6. Distributing and Maintaining Your Module

If you want to share your module with the community, you can:

  • Publish it on Dolistore (the marketplace for Dolibarr modules).
  • Make the code available on GitHub/GitLab for collaborative updates.
  • Ensure compatibility with new Dolibarr versions by testing and updating the module regularly.

Conclusion

Integrating a custom module into Dolibarr allows you to adapt the ERP to specific needs and add tailored functionalities. By following these steps—from module creation, configuration, installation, and testing—you can enhance Dolibarr without modifying its core.

With some PHP development knowledge and proper update management, you can optimize your business operations by integrating features designed specifically for your needs.

Have you ever integrated a custom module into Dolibarr? Share your experience in the comments!

Comments

Log in or register to post comments