Skip to content
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

Adding Hooks in bookkeeping card #28737

Merged
merged 8 commits into from
Mar 18, 2024
Merged

Adding Hooks in bookkeeping card #28737

merged 8 commits into from
Mar 18, 2024

Conversation

AWeerWolf
Copy link
Contributor

NEW|New Adding Hooks in bookkeeping card

@eldy
Copy link
Member

eldy commented Mar 10, 2024

Can you describe the use case you have that need a hook before actions ?

@eldy eldy added the Discussion Some questions or discussions are opened and wait answers of author or other people to be processed label Mar 10, 2024
@AWeerWolf
Copy link
Contributor Author

For my module "Bookkeeping Template" I only use "onConfirmCreate_onAfterCreateEmptyLine" and "onCreate_onAfterShowFields"
I put the other hooks for future use by other programmers.
The Hook "onBeforeActions" is the same as the one generated by the "Module and Application Builder".
So if your "Module builder is creating the hook, I thougth I shoud do the same in the "bookkeeping card".
This hook could be use for exemple if you want to check if the "doc_ref" already exist and warn the user.

If you want me to delete some hooks, juste let me know.

@AWeerWolf
Copy link
Contributor Author

Hello,
What do we do with the missing hooks ?
Seems that in the mean time we have a conflict with another branch.
Regards,
AWeerWolf

@eldy
Copy link
Member

eldy commented Mar 16, 2024

onBeforeActions

I can't find any hook onBeforeActions on modulebuilder template.
May be you are thinking of hook "doActions" ? Can you point me the file and line of code with such hook onBeforeActions ?

@AWeerWolf
Copy link
Contributor Author

Yes, this is the doActions.

As there is one hook before action and one after action, i find the name "onBeforeAction" more clear.

You want me to change ?

@eldy
Copy link
Member

eldy commented Mar 16, 2024

If you need to make code before any action, why don't you use the hook doAction ?

@AWeerWolf
Copy link
Contributor Author

Je ne comprends pas bien le but de cette discussion.
Il n'y avait aucun hook dans la page bookkeeping card.php
J'ai donc ajouté les hooks suivants:

  • "onBeforeActions" qui s'appelle habituellement "doAction" (Je trouve ce nom mal approprié, donc je l'ai renommé)
  • "onAfterActions"
  • "onBeforeView"
  • "onAfterView"
    Je n'utilise aucun de ces hooks donc si vous préférez, on peut les supprimer ou les renommer.

J'ai aussi ajouté les hooks suivants :

  • onConfirmCreate_onAfterCreateEmptyLine
  • onCreate_onAfterShowFields
    J'utilise uniquement ces 2 hooks dans mon module "BookKeeping Template" (Modèles d'écritures comptable pour faciliter l'encodage d'OD)

@eldy
Copy link
Member

eldy commented Mar 17, 2024

PR must be atomic: See CONTRIBUTING.md file (adding several hooks at different places reduce probability to have the PR merged) For exemple here PR is blocked due to bad name of hook: The name of hook to manage actions is "doAction" (executed before any common action), even if name is not fantastic, it is the one used everywhere, so we must reuse the same if we introduce it on a page that does not have it.

@eldy eldy added PR to fix - See feedback in comments PR needs to be fixed to be integrated (some comments should describes the fix to do) and removed Discussion Some questions or discussions are opened and wait answers of author or other people to be processed labels Mar 17, 2024
@AWeerWolf
Copy link
Contributor Author

Now, it's clear.
I will rename the hook, delete the unnecessary ones and make a new submit.

@eldy eldy merged commit 79b236e into Dolibarr:develop Mar 18, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR to fix - See feedback in comments PR needs to be fixed to be integrated (some comments should describes the fix to do)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants