Duplicate lines when I insert

I have a problem with inserting data inside a custom subpanel. Let me explain better:
I am inside a custom module, inside which there is a subpanel of another custom module, so I create a new record in this subpanel and sometimes, not always, at the end of the insertion, two identical records appear (duplicates).
I don’t do any operations on the relationships (add or delete), there are no errors and I don’t understand this behavior, as mentioned it doesn’t always do it, but only sometimes. Does anyone know the reason? Are there cases that describe such behavior? How can I solve it? Thank you.

I use Suitecrm 7.12.12

Start by figuring out if you have a problem saving or viewing.

If it is saving, you’ll have two actual rows in the database table, and you should suspect some sort of re-entry into the code that adds the row. For example, maybe you have both a logic hook and a workflow doing the same thing, or two hooks, or a hook that has cyclical behaviours (it saves beans or relationships, and these in turn generate new hook calls).

If it viewing you will see a single table in the database row, but then the problem is, why does it how duplicated in the view? I would suspect some buggy SQL query, because depending on the way you JOIN (INNER JOIN, LEFT JOIN, etc), SQL combines the data in different ways, so it might duplicate that row to express some variation in the other table to which you’re joining it.

Sometimes custom modules generate queries that aren’t very tested, they might have some problem that wasn’t immediately obvious to people developing the query generation in different circumstances.

Check logic hooks of both modules. And also save methods in these module main class files.

Are there actually two records created or is just displaying the same record twice. These are two different issues.