Custom module activation bug

Hi, I’m trying to develop a custom module using the built-in generator in Dolibarr, but I’m stuck because a menu item is not appearing.

I’ve already checked the module name, number, and possible errors, and everything seems correct. The module itself appears to work: the CSS/HTML changes I added are applied correctly and usable.

Normally, I enable the module from the “Modules/Applications” tab. However, in the “App/Module Generator” tab, the module’s toggle always appears as disabled. This made me think I needed to disable it from “Modules/Applications” and enable it from the generator tab instead.

After doing that, I noticed something confusing: clicking the toggle in the generator tab appears to have no visual effect (it stays on “disabled”), but in reality it does enable the module. I can tell because my CSS/HTML changes are applied again, and the module shows as enabled in the “Modules/Applications” tab.

Steps to reproduce:

  1. Enable the custom module from the “Modules/Applications” tab.
  2. Go to the “App/Module Generator” tab → the module toggle appears disabled.
  3. Click the enable switch → it still appears disabled (no visual change).
  4. Disable the module from the “Modules/Applications” tab.
  5. Click the enable switch in the generator tab → the module is actually enabled, but the toggle still appears disabled.

Additional observation:
It seems that clicking the toggle in the generator tab can only activate the module, not properly reflect or control its real state. This likely happens because the toggle relies on its own displayed state rather than the actual module status. As a result, the UI is misleading: even when the module is already enabled, the switch still appears disabled and behaves inconsistently.

At this point, I’m not sure if I’m doing something wrong or if this is a bug. What I’m certain of is that the behavior is inconsistent, and I’m concerned it may be related to the issue with the missing menu item.

Environment:

  • Dolibarr version: 22.0.3
  • OS: Ubuntu 24.04.4 LTS (x86_64)

EDIT:
I looked into the logs and found this error:

2026-04-01 09:41:48 ERR     151.47.201.72      2311   1000 DoliDBMysqli::query Exception in query instead of returning an error: Duplicate key name 'uk_richiestadocumenti_fk_object'
2026-04-01 09:41:48 ERR     151.47.201.72      2311   1000 DoliDBMysqli::query SQL Error message: DB_ERROR_KEY_NAME_ALREADY_EXISTS Duplicate key name 'uk_richiestadocumenti_fk_object' From /var/www/html/debugbar/class/TraceableDB.php:362.

Hey @Antonomasia. Do you run your dolibarr with debug logs? do that reveal anything else?

What about your php/webserver logs, do they reveal anything?

Yes I am.

Where can I find the webserver logs?

I don’t know your setup

Hi @Antonomasia

Your system is trying to create an index/constraint with a name that already exists in the same table.

Run this SQL: SHOW INDEX FROM your_table; and look for uk_richiestadocumenti_fk_object

Only if sure run this ALTER TABLE your_table DROP INDEX uk_richiestadocumenti_fk_object;

Thanks & Regards
Saikat Koley
Software Developer(Dolibarr)
Call/WhatsApp : +919903256573
Email : saikatkoley@hotmail.com
https://www.linkedin.com/in/saikatkoley/

1 Like