Creation of an object on the fly


I have a field function on an O2M where I would like to add elements for visualization only.
The setter does not write a record in the database (in my case PartyRelation), but some information somewhere else.
With those information, I would like to create on the fly in the getter a PartyRelation object, in order to be displayed in the list.

Is this possible ? (In the long term, this list should be able to display the records from the database and the ones above. Not sure about the feasability of it)

I think with Proteus it’s possible, but that is for the tests.

Thank you for your answers.

No, this is not possible as the getter of a One2Many should return the ids of the related records which IIUC does not exist for you case.

I’m wondering if it’s not better to just have a table_query model to compute the data you want to visualize and use such model in the O2M. That way you will have the records shown by using a One2Many field to the new model.

From here you will be able to add any function fields on the model and store such values somewhere else.

Does it make sense?

Thank you for your quick reply.
I never used the table_query, do you have an example that would look like my case maybe ?
Otherwise I will see what I can do.

For example the party_relationship module defines a table query which is used to automatically compute the reverse relations based on the normal relations. I guess this is the simpler one.

Otherwise, if you give us more details on what you are trying to achieve we may provide better advices or some example code.