Best/Preferred way to create new objects

Hi everyone. I am new to Dolibarr development and I am developing my own module.

My module needs to have the ability to create other objects in the core Dolibarr system. Things like creating new Third Parties, Contracts, and so on.

Can someone please tell me what is the best or preferred methodology to create those objects?

Do you want to utilize Hooks, or Triggers, or directly use the class?

Please let me know. Thanks

Nevermind. I figured out the best way. I will leave this here for other developers who might find this useful.

The best way to create core objects is to create your own php file, and in this file follow the CRUD/REST methodology. For each of the CRUD methods, instantiate an object (like Societe) and then utilize that objects CRUD methods to create it. There are methods in each object like create, view, update, delete. Also after you do what it is you need to do, you can fetch other data from the object.

From your HTML forms, you can use javascript/jquery and such to call POST, PUT, GET, DELETE using ajax calls or by submitting the forms.

Everything works great and is very clean and efficient this way.

Hopefully this helps out other developers.

2 Likes