Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
3183 Представления

Hi,

Is it possible to create a record in a model B while creating a record in model A depending on some conditions.

if so, can any one help with the way to do it :)

Thank you.

Аватар
Отменить

How to override Odoo functions: https://goo.gl/4BkizH

Лучший ответ

Hi,

You can override the create method of the model A and then calling create function of the model B you can create the record.

Sample:

class Model_A(models.Model):
_inherit = 'model.a'

@api.model
def create(self, values):
res = super(Model_A, self).create(values)
vals = {
'field_1': 'test',
'field_2': 'test'
}
self.env['model_b'].create(vals)
return res

Thanks

Аватар
Отменить
Автор

Thank you very much

Related Posts Ответы Просмотры Активность
5
июн. 20
31652
1
дек. 19
4189
2
дек. 23
14678
0
окт. 23
33
3
окт. 23
788