Control before deletion (action)


I would like to perform a check when deleting a record (click the deleted button on the form).
Except I haven’t seen anything like onDelete or anything else, can you tell me how this is done?


PS :
I saw a canDelete but I would like to be able to make a request in db to check if there are links with other objects before authorizing the deletion

You can override remove method.


I did not find this method? do you have his name?

Thanks for your answers.

Try like this

i’m thinking about it, I’m new to development, but the idea in my mind is that when a user wants to delete a record, its just make inactive. then we can check these records through the database or do a complete cleaning.
please let me know your answer so that I can improve myself if I have a mistake as an idea or if it is open to improvement.
best regards

could listeners be the solution ?

Hi ple-essieux,

Thanks for your help

I just need to create my own packages and extend my entity’s class repository ? The code you show is already in AOP, it’s for an object that I created that I want to overload the delete button to add controls before deletion.

Like @ple-axelor said, you can overide the remove function in the dao/repository so you can edit this to inactive rather than deleting. For this, you have to create a new class, extends from the repository and bind it in the module file.

WOW it’s starting to get tense lol the dao package is a self-generating package, I have to create my own packages in the java source directory? do you have an example please?

When I develop, I use my own package because I use custom module.
I create a module like this :
and I configure it with settings.gradle and build.gradle at the root of the axelor project

So I too create my own modules under eclipse, however when you create your DOMAIN XML files it generates the repositories even if you have a custom module, that’s where I’m lost… I hope I got it right Explain.

Yeah when you create new domain, it create new repositories.
If you want to add properties to extistant domain, you have to create a domain file in your own module and set the exact name and package that the axelor domain which already exist.

Initial Invoice domain :

Add a propertie named contract to Invoice domain :