-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancements and Optimizations for the Module Builder #32460
Comments
@eldy What do you think? Which points should be prioritized? |
FIX Issue #32460 db prefix for module builder
No preference. Point 12 must also NOT be done for foreign key. See https://wiki.dolibarr.org/index.php/Language_and_development_rules#Foreign_keys |
Hello @eldy , Thank you for your detailed feedback! Here are some clarifications and arguments regarding points 3 and 12. Point 3: Using
|
Yes if foreign key is between a table of external module and another table of same external module, it should be ok. No risk of breaking dolibarr internal features.
Yes but only beteween tables of the same module. |
Feature Request
Enhancements and Optimizations for the Module Builder
A series of improvements to make the Module Builder more robust, user-friendly, and capable of generating clean, maintainable, and modern code.
Use case
The Module Builder is a key tool for developers to quickly generate Dolibarr modules and objects. However, the current implementation has some limitations:
By addressing these limitations, the Module Builder can generate code that is cleaner, more maintainable, and better aligned with Dolibarr's core practices.
Suggested implementation
Suggested steps
Proposed Improvements for the Dolibarr Module Builder
Action: Add strict typing to all methods (PHP 7.4+ or higher) to ensure consistency in returned data (
int
,string
,void
, etc.).2. PHPDocs Update
Action: Update PHPDoc comments for all generated methods and classes, specifying parameter types, return types, and possible exceptions.
3. Use
__DIR__
Instead ofdol_include_once
Action: Replace all occurrences of
dol_include_once
with__DIR__
for cleaner and more portable path handling.4. Specify If the Object Manages Lines
Action: Add an option in the configuration interface to specify if the object manages lines (e.g., for invoices). If not, skip generating related code.
5. Specify If the Object Manages Statuses
Action: Add an option to indicate if the object manages statuses (e.g., "Pending", "Validated", "Paid"). If not, exclude status management code.
6. Select Available Tabs
Action: Allow selection of required tabs for the object (e.g., contacts, history). Exclude unnecessary tabs and related code.
7. Dynamically Name Statuses
Action: Provide the ability to customize status labels in the configuration interface (e.g., "In Progress", "Completed").
8. Meaningful Trigger Names
Action: Generate clear and meaningful names for triggers, avoiding generic names like
mymodule_trigger
.9. Multicompany Management
Action: Add an option for Multicompany support. Generate the necessary code to handle shared or non-shared references.
10. Select Actions Available on the Object Card
Action: Allow users to choose available actions on the object card (e.g., clone, email) and generate corresponding code.
11. Use
$db->prefix()
Instead ofMAIN_DB_PREFIX
Action: Replace all occurrences of
MAIN_DB_PREFIX
with$db->prefix()
to properly handle table prefixes in a multi-company environment.12. Foreign Keys and Index Management
Action: For
link
-type fields, propose creating a foreign key in the database, with options for cascading delete. AddUNIQUE
indexes for unique fields andNOT NULL
constraints for required fields.13. Improved
accessforbidden
HandlingAction: Enhance generated
accessforbidden
conditions by supporting OR conditions.14. Email and
trackid
HandlingAction: Ensure the proper generation of
trackid
values for emails, avoiding generic placeholders likexxx
.15. Remove Placeholder
xxx
Action: Clean up generated code by removing all placeholder values like
xxx
.16. Rename
myobject
OccurrencesAction: Replace all occurrences of
myobject
in generated code with the specific object or module name (e.g.,invoice
).17. Menu Generation Option
Action: Provide an option to generate menus for the object, and adapt the generated code accordingly.
18. Access Rights Generation Option
Action: Allow users to decide whether access rights should be generated for the object and adjust the code based on their choice.
19. Clean Up PDF Model Code
Action: Avoid generating code related to PDF models if the object does not require this functionality.
20. Improve Access Rights Management in ModuleBuilder
Action: Automatically update access rights in files when modifications are made via ModuleBuilder.
21. Fix Event Management for Object Creation
Action: Ensure event handling works correctly during the creation of objects.
The text was updated successfully, but these errors were encountered: