This question has been flagged
1 Reply
2802 Views

Hi all,

v 10.0

I am trying to create child records through a One2many relationship.

The child records inherit some field values from the parents through a 'related' relationship.

I find that in the business logic the parent and children are created at the same time and then commited alltogether.

Meaning at the time of creation the parent values have not yet been commited to the DB but are living in cache (i presume).


How is it possible to use these cache values to populate the child records ?

Regards. 

Avatar
Discard
Best Answer

the answer depends whether you want to create the children in the front end or in the back end

In the front end, you would probably use a @api.onchange() decorator with your method. In this case, the onchange method is loaded in the front end, and from the children you should be able to access the parent values as they are in a "cache". Practically, there is no difference in the coding.

In the backend, the methods are called on records, so before they are created, you can't access their value... However, if you create them from backend, then you must have their values in a dictionary, so you should be able to get the required values from it.

hope this helps.

Avatar
Discard

I want to create children-records in the front end to imitate a conversation structure like this one or, rather, like that of Reddit.
Where can I find more information e.g. about children-records?

a. I thought I'd create a one-to-many relationship between a record set and itself, which is possible in other software. I am yet to find out that it's possible in Odoo.
b. The field type Lines doesn't help one reach such a goal.