Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3647 Переглядів

Hello,
In scenario having 2 models, 'my.model1' & 'my.model2', 'my.model1' has a One2many field to 'my.model2' named 'link_ids'.
A custom method in 'my.model1' that generates data and create records in 'my.model2',
Should I do it like,


Solution 1st
def my_method(self):
for record in self:
### record_field_dictionary generated here
record.update({'link_ids': [(0, 0, record_field_dictionary)]})
Solution 2nd
def my_method(self):
for record in self:
### record_field_dictionary generated here, logic is different than solution 1st.
self.env['my.model2'].create(record_field_dictionary)


Question 1: Which of the solution is better performance?
Question 2: I am aware of there's also @api.model_create_multi decorator, do I need to override the default create method to use it?

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
квіт. 20
4080
1
лист. 17
4265
2
груд. 20
8309
2
груд. 23
10290
0
лист. 22
3931