Developing custom module

Hello,
I developed a new custom module, this module has an object called “data center”. I want when activating this module to add a new attribute to the “Ticket” module called centerid and for sure there will be a selector in the add ticket forms. I did it manually and added the new attribute from the ticket dashboard and added a piece of code on the add ticket form because it has some rules like the center should belong to a specific thirdparty. But I want this to be done automatically not manually by me because every time I do upgrade to a new version it removes my custom code.
Any kind of help?
@ksar

Hello,

You have an exemple how to create extrafields during init of your module :

You need to call the function dolibarr: ExtraFields Class Reference

@ksar thanks for your answer. But, the problem here is that i the each “thirdparty” have many “centers” so in the create ticket form at first i will select the thirdparty and then the “centers” selector should returns only centers of the thirdparty. This case i couldn’t handle it correctly without the hard-code from my side.
Do you have any advice about how to do it?

Hi @muhannedzo
You can add a dictionary “data centers” in your module and a combo to retrieve them

@sonikf i thought about this solution but here the centers are not static, each thirdparty have different centers.

I believe the only solution is to create:

  • a data-center table (or use a dictionary as from sonikf)
  • a table that relates data centers to third parties
1 Like